+ Reply to Thread
Results 1 to 9 of 9

Last Column number in duplicate column headers?

  1. #1
    Registered User
    Join Date
    12-19-2018
    Location
    Gurgaon
    MS-Off Ver
    11
    Posts
    9

    Last Column number in duplicate column headers?

    I have 2 tabs.
    Tab 1 has 5 column headers - price ,stock ,stock ,price ,stock

    tab 2 has price. Now I want to return 4 in front of price as in tab 1, last price has column number 4

    So, I tried using match function but it gave me 1 instead of 4 as it gave me the first price location and not the last.

    Please help

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Last Column number in duplicate column headers?

    Use:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    12-19-2018
    Location
    Gurgaon
    MS-Off Ver
    11
    Posts
    9

    Re: Last Column number in duplicate column headers?

    Quote Originally Posted by Olly View Post
    Use:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks a lot for the formula. This is not working on VBA. Can you please tell me what changes are required to be made in this to make it use in vba ?

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Last Column number in duplicate column headers?

    If you need a VBA solution, you could use something like:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-19-2018
    Location
    Gurgaon
    MS-Off Ver
    11
    Posts
    9

    Re: Last Column number in duplicate column headers?

    Quote Originally Posted by Olly View Post
    If you need a VBA solution, you could use something like:

    Please Login or Register  to view this content.
    sir, how do I use it?
    Suppose I have tab2 price(lookup value) in a1, range (tab1) in a1 to a10 and lets say I want my result in tab2 b1 range. Please suggest as to how to use it?

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Last Column number in duplicate column headers?

    If you don't know how to apply that simple function, then why do you want a VBA solution instead of a formula?

  7. #7
    Registered User
    Join Date
    12-19-2018
    Location
    Gurgaon
    MS-Off Ver
    11
    Posts
    9

    Re: Last Column number in duplicate column headers?

    I figured it out and its working in VBA. Thanks a lot for the help.
    Last edited by tanmayagrawal; 08-22-2019 at 03:36 AM.

  8. #8
    Registered User
    Join Date
    12-19-2018
    Location
    Gurgaon
    MS-Off Ver
    11
    Posts
    9

    Re: Last Column number in duplicate column headers?

    Olly, I am facing a strange problem. Today I bought one online windows server and their I used this function but this error is coming
    run time error 91 - Object variable or with block variable not set

    This code is working perfectly fine on my system but not working on server.
    What can be the problem according to you ?

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Last Column number in duplicate column headers?

    Post your code - or better still, attach your workbook.

+ 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. [SOLVED] How to find the Duplicate Column Headers in entire workbook
    By sandeepgoud88 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-26-2019, 01:21 PM
  2. Replies: 8
    Last Post: 06-25-2015, 08:59 AM
  3. [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
  4. Combining Column Data When There are Duplicate Row Headers
    By Jhmman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-10-2014, 09:44 PM
  5. Replies: 0
    Last Post: 09-11-2013, 09:54 AM
  6. [SOLVED] Return Column Headers based on row rank with duplicate values in row
    By carlwin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-31-2013, 12:24 AM

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