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
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
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
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?
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...
...or...this:![]()
Please Login or Register to view this content.
Does that help?![]()
Please Login or Register to view this content.
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.
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
Then use RowPos in your AutoFilter code.![]()
Please Login or Register to view this content.
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks