+ Reply to Thread
Results 1 to 11 of 11

Excel VBA to rename Column headers with same name/Value

  1. #1
    Forum Contributor
    Join Date
    09-20-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    275

    Question Excel VBA to rename Column headers with same name/Value

    Dear all,
    I have around 110 columns and this 110 will not be constant.

    Among these 110, around 8 columns carry same header name as 'Engineer name'.

    I want VBA code rename these headers as 'Engineer1' to 'Engineer8' in sequence from Left to right.
    Columns where these 8 'Engineer name' is not constant but they do appear for sure.

    Please help.

  2. #2
    Forum Contributor
    Join Date
    04-15-2015
    Location
    beirut
    MS-Off Ver
    2010
    Posts
    107

    Re: Excel VBA to rename Column headers with same name/Value

    type this formula in A1 and drag to right
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Excel VBA to rename Column headers with same name/Value

    Hi mchilapur,

    See if this code works for you in the attached.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Contributor
    Join Date
    09-20-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    275

    Re: Excel VBA to rename Column headers with same name/Value

    @MarvinP ..Yes...You are almost there..
    One small concern, it is possible to start the count from '1'..? Currently it starts from '2'..
    Last edited by mchilapur; 08-26-2015 at 12:19 AM.

  5. #5
    Forum Contributor
    Join Date
    04-15-2015
    Location
    beirut
    MS-Off Ver
    2010
    Posts
    107

    Re: Excel VBA to rename Column headers with same name/Value

    your message for me or for mchilapur

  6. #6
    Forum Contributor
    Join Date
    09-20-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    275

    Re: Excel VBA to rename Column headers with same name/Value

    Hi salim, Marvin has replied for my post, so i replied him back...I have quoted @MarvinP to avoid confusion..

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Excel VBA to rename Column headers with same name/Value

    Hi,

    Try this
    Please Login or Register  to view this content.
    The code above will put a 1 on all, even if there are no duplicates in the list. I didn't think you wanted that.

  8. #8
    Forum Contributor
    Join Date
    09-20-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    275

    Re: Excel VBA to rename Column headers with same name/Value

    @ Marvin...thanks for your response..
    I looking for something different..
    Your first code was correct, but will rename duplicates,say 'Engineer' as :'Engineer', 'Engineer2','Engineer3'...
    I want your code to rename them as::'Engineer1', 'Engineer2','Engineer3' for any duplicate values..

    Can you please modify it..?

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Excel VBA to rename Column headers with same name/Value

    OK mchilapur,

    Try this code where it will not put a number after the name if it is unique. It will put the numbers 1 after a name that has a duplicate in row 1.
    Please Login or Register  to view this content.
    I now think this is what you are looking for. You can pay me for my effort by clicking on the "Add Reputation" under this post.

  10. #10
    Forum Contributor
    Join Date
    09-20-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    275

    Re: Excel VBA to rename Column headers with same name/Value

    Thanks for your efforts...But i am not that reach to pay you for it...I can only pay one honest respect for all the knowledge you have...

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Excel VBA to rename Column headers with same name/Value

    Hi mchilapur,

    Thanks for the kind words. I'm glad my third attempt finally solved your question. If you click on the "Add Reputation" star it simply gives me some assurance that my free work is appreciated. It costs you nothing but reassures me that my free help is worth a "thank you". Again, thanks for suggesting I have some knowledge of Excel.

    Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel VBA rename pictures name in column B to be the string from Column A
    By sofianeuk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2015, 05:25 PM
  2. [SOLVED] listbox with column headers as a specific sheet column headers
    By ANDREAAS in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-07-2014, 04:40 AM
  3. Replies: 2
    Last Post: 05-09-2012, 01:30 PM
  4. Macro to automatically rename row headers
    By Zyphon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-09-2008, 04:41 AM
  5. Excel - returning column headers in a seperate column
    By ExcelConfused in forum Excel General
    Replies: 1
    Last Post: 03-28-2006, 09:55 AM
  6. Excel column headers
    By Tara in forum Excel General
    Replies: 1
    Last Post: 01-02-2006, 08:25 AM
  7. Excel column/row headers
    By mduckworth77 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-22-2005, 08:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1