+ Reply to Thread
Results 1 to 8 of 8

Find a column by title even if its been moved and show contents on another sheet

  1. #1
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Find a column by title even if its been moved and show contents on another sheet

    Hi, I'm trying to make sure I can copy a column to another worksheet even if the column has been moved in original sheet.
    In other words copy column 5 from main sheet to second sheet even if column 5 is called the same but has moved to column 9

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: Find a column by title even if its been moved and show contents on another sheet

    do you mean actually copy, or just reference the values from it?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Find a column by title even if its been moved and show contents on another sheet

    If you create a Dynamic Named Range for the column, you can always reference it by name...even if it moves.

    Example:
    • Select Col_E on a Sheet1
    • Insert.Name.Define
    ...Names in Workbook: SourceColumn
    ...Refers to: =Sheet1!$E:$E
    ...Click: OK

    Now, from anyplace in the workbook you can press F5 and choose SourceColumn...and it will select the SourceColumn range.
    If you insert columns before Sheet1!$E:$E so that data now exists in Col_M, SourceColumn will refer to Sheet1!$M:$M.
    You can also use the SourceColumn as a range reference in VBA.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Re: Find a column by title even if its been moved and show contents on another sheet

    Thanks! I wouldn't have thought of that but I've already defines names so of course! Could you please give an example of how I can use it in VBA?

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Find a column by title even if its been moved and show contents on another sheet

    Quote Originally Posted by KAPearson View Post
    Thanks! I wouldn't have thought of that but I've already defines names so of course! Could you please give an example of how I can use it in VBA?
    I believe something like this would work...
    Please Login or Register  to view this content.
    ...or...this:
    Please Login or Register  to view this content.
    Does that help?

  6. #6
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Re: Find a column by title even if its been moved and show contents on another sheet

    Ill give the code so you might be able to see what Im doing.
    I filter a column in Main then copy it to main2 but if the column moves...

    Please Login or Register  to view this content.

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Find a column by title even if its been moved and show contents on another sheet

    Assuming you want to autofilter on the "Dept" column, you need to determine which ordinal position in the filter data headings contains "Dept".
    Try something like this...
    With the headings in Row_1
    Please Login or Register  to view this content.
    Then use RowPos in your AutoFilter code.

  8. #8
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Re: Find a column by title even if its been moved and show contents on another sheet

    Thank you Ron, I'll give that a go tomorrow now as its latee over here in the UK.
    I'll get back to you. Thanks and goodnight.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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