Macro to Select Multiple Columns by Columns Specific Headings to Delete Dupes
Solved/Closed
jackied25
TrowaD
- Posts
- 1
- Registration date
- Friday February 28, 2020
- Status
- Member
- Last seen
- February 28, 2020
TrowaD
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Related:
- Excel vba select multiple columns by header name
- Vba select multiple columns - Best answers
- Excel vba delete multiple columns based on header - Best answers
- Rearrange multiple columns in four columns, VBA ✓ - Forum - Excel
- VBA find column by name and sort ✓ - Forum - Excel
- Excel vba delete multiple columns based on header ✓ - Forum - Excel
- Macro to Deleting Multiple Rows ✓ - Forum - Excel
- Excel VBA - Selecting multiple sheets - How-To - Excel
2 replies
TrowaD
Mar 2, 2020 at 11:50 AM
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Mar 2, 2020 at 11:50 AM
Hi Jackied,
Not sure what you mean by select column by name? Do you mean by Header name or Column letter or Named range or something else?
And where are those names located for Excel to know which columns need to remove duplicates? Or do you want to be prompted for each column?
Best regards,
Trowa
Not sure what you mean by select column by name? Do you mean by Header name or Column letter or Named range or something else?
And where are those names located for Excel to know which columns need to remove duplicates? Or do you want to be prompted for each column?
Best regards,
Trowa
TrowaD
Mar 3, 2020 at 12:17 PM
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Mar 3, 2020 at 12:17 PM
Hi Jackied,
Having a second look at your title, the following code might be what you are after:
Every column with a header named "Dupes" will get it's dupes removed. Change the word Dupes on the 3rd code line if you have/want another header name to trigger the removal of duplicates.
Best regards,
Trowa
Having a second look at your title, the following code might be what you are after:
Sub RunMe() For Each cell In Range(Cells(1, 1), Cells(1, Columns.Count).End(xlToLeft)) If cell.Value = "Dupes" Then Range(Cells(2, cell.Column), Cells(Cells(Rows.Count, cell.Column).End(xlUp).Row, cell.Column)).RemoveDuplicates Columns:=1 End If Next cell End Sub
Every column with a header named "Dupes" will get it's dupes removed. Change the word Dupes on the 3rd code line if you have/want another header name to trigger the removal of duplicates.
Best regards,
Trowa