Good morning!
I am working on code that will distribute a range of cells from one tab to another.
Here's how it works:
Tab.2 has 10 columns of data and thousands of rows of customer information.
Customer #, Customer Code, Mr/Mrs/Ms, Name, Age, School, School Zone, Zip Code, City, State
What I want to do is to be able to hide some of these columns in Tab.2 (it can be random - it is dependent on the column headers in Tab.1), and then copy that range of cells from Tab.2 to an area on Tab.1.
This is what Tab.1 looks like:
Customer #, Name, Age, School, Zip Code
The code that I am using is pasted below. I am not sure how to modify it to bring in only the columns of data that are shown (not that are hidden. Again, any of the columns can be hidden - it's up to the user to determine what they want on Tab.1).
Sub CopyRangeToAnotherSheet()
Sheets("Tab.2").Range("A1:M999").Copy Destination:=Sheets("Tab.1").Range("B2:N999")
End Sub
Does anyone know any way of going about this?
Thank you!
I am working on code that will distribute a range of cells from one tab to another.
Here's how it works:
Tab.2 has 10 columns of data and thousands of rows of customer information.
Customer #, Customer Code, Mr/Mrs/Ms, Name, Age, School, School Zone, Zip Code, City, State
What I want to do is to be able to hide some of these columns in Tab.2 (it can be random - it is dependent on the column headers in Tab.1), and then copy that range of cells from Tab.2 to an area on Tab.1.
This is what Tab.1 looks like:
Customer #, Name, Age, School, Zip Code
The code that I am using is pasted below. I am not sure how to modify it to bring in only the columns of data that are shown (not that are hidden. Again, any of the columns can be hidden - it's up to the user to determine what they want on Tab.1).
Sub CopyRangeToAnotherSheet()
Sheets("Tab.2").Range("A1:M999").Copy Destination:=Sheets("Tab.1").Range("B2:N999")
End Sub
Does anyone know any way of going about this?
Thank you!