Link to home
Start Free TrialLog in
Avatar of Shyretta Jenkins
Shyretta Jenkins

asked on

Macro

I have a spreadsheet with column headers. I would like to create a macro that would rename the column headers based on the value. For instance, one column is Product ID. I would like to change that to PALLET ID. There are other columns that I would need to rename as well.

Because the column place can be different depending on the file, I would like the macro to be able to find that column name and rename it based on the set criteria.

Product ID = PALLET ID
Div = CATEGORY

So forth and so on.
ASKER CERTIFIED SOLUTION
Avatar of Jeff Darling
Jeff Darling
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This will work, you just have to add in new conditions for the Headers you are looking for:

Sub UpdateHeader()

    For i = 1 To 100
        Columns(1).Select
        If Columns(i).Value = "Product ID" Then
            Columns(i).Value = "PALLET ID"
        ElseIf Columns(i).Value = "Div" Then
            Columns(i).Value = "CATEGORY"
        End If
    Next

End Sub

Open in new window

Avatar of Shyretta Jenkins
Shyretta Jenkins

ASKER

Thank you so much! This was a great help!