Hello,
I am a bit of a VBA novice, and have ran into a recent issue trying to copy and paste a named range from one worksheet into a specific cell on another worksheet, based upon a value.
I've attached a sample data set so you can see what I'm talking about, but the sheet works as follows.
On Worksheet "Sample":
1. A user selects a "city" from a drop-down - Cell B1
2. A vlookup is written in D1 that looks up a potential $ value for that city selected in B1
3. A range named region_potential (H4:H44) is calculated by multiplying the values in G4:G44 * the potential $ value in D1
On Worksheet "Cities":
1. There is a list of all the potential cities that can be selected from the drop-down in cell B1 on the "Sample" Worksheet. They are listed horizontally across columns, D2:M2 on the "Cities" worksheet
What I would like to do:
1. Write a macro that copies the data in the range region_potential from the "Sample" worksheet, and paste it into the "Cities" worksheet under the column header for the city selected in the "city" drop-down in cell B1 on the "Sample" worksheet.
So if "Toronto" is chosen, the values in the range: region_potential (H4:H44) on the "Sample" worksheet will be pasted under the "Toronto" header on the "Cities" worksheet. The values pasted should override any previous values in there, as I will be using this table for future hlookup & index/match formula's.
This way for any city selected I will be able to simply run the macro to paste that cities values under that respective city in the "Cities" worksheet
Any help is greatly appreciated, and as I mentioned previously a sample worksheet is attached.
Thanks!
I am a bit of a VBA novice, and have ran into a recent issue trying to copy and paste a named range from one worksheet into a specific cell on another worksheet, based upon a value.
I've attached a sample data set so you can see what I'm talking about, but the sheet works as follows.
On Worksheet "Sample":
1. A user selects a "city" from a drop-down - Cell B1
2. A vlookup is written in D1 that looks up a potential $ value for that city selected in B1
3. A range named region_potential (H4:H44) is calculated by multiplying the values in G4:G44 * the potential $ value in D1
On Worksheet "Cities":
1. There is a list of all the potential cities that can be selected from the drop-down in cell B1 on the "Sample" Worksheet. They are listed horizontally across columns, D2:M2 on the "Cities" worksheet
What I would like to do:
1. Write a macro that copies the data in the range region_potential from the "Sample" worksheet, and paste it into the "Cities" worksheet under the column header for the city selected in the "city" drop-down in cell B1 on the "Sample" worksheet.
So if "Toronto" is chosen, the values in the range: region_potential (H4:H44) on the "Sample" worksheet will be pasted under the "Toronto" header on the "Cities" worksheet. The values pasted should override any previous values in there, as I will be using this table for future hlookup & index/match formula's.
This way for any city selected I will be able to simply run the macro to paste that cities values under that respective city in the "Cities" worksheet
Any help is greatly appreciated, and as I mentioned previously a sample worksheet is attached.
Thanks!