Rename columns headings VBA in excel

vbanewbie68

Board Regular
Joined
Oct 16, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi Sir/madam

I have a question to ask please in relation to VBA macros as see below.

When I download data from a platform that is linked to a donation page I would like the macro to rename the column headings. Please find attached the highlighted information below: to get the macro to rename the First Name and the Last Name to Donor First Name and Donor Last Name.

Thank you

Best Regards

Vbanewbie68
 

Attachments

  • headings.gif
    headings.gif
    18.8 KB · Views: 163

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Like this?

VBA Code:
Sub RenameHeadings()
  With Rows(1)
    .Replace What:="First Name", Replacement:="Donor First Name", LookAt:=xlWhole
    .Replace What:="Last Name", Replacement:="Donor Last Name", LookAt:=xlWhole
  End With
End Sub
 
Upvote 0
Solution
Like this?

VBA Code:
Sub RenameHeadings()
  With Rows(1)
    .Replace What:="First Name", Replacement:="Donor First Name", LookAt:=xlWhole
    .Replace What:="Last Name", Replacement:="Donor Last Name", LookAt:=xlWhole
  End With
End Sub

Hi Peter_SSs

Thank you for this and it works on my end successfully. :)


Regards

V
 
Upvote 0

Forum statistics

Threads
1,215,133
Messages
6,123,231
Members
449,091
Latest member
jeremy_bp001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top