indirect reference in macro to select different worksheets

jobub

New member
Joined
Feb 18, 2013
Messages
1
Reaction score
0
Points
0
I dind't find the macro forum so I'll try here.. I have a data input page with a drop down list to choose which worksheet to save the data to. I have a "save" macro that is saveing the data to a worksheet but i dont' know how to get the macro to look at what is chosen in the list and save to that particular worksheet. I figure I need some sort of indirect instruction in the macro. Please help. Thanks
 

Palmetto

New member
Joined
Apr 21, 2012
Messages
5
Reaction score
0
Points
0
You should post your code for someone to review and help with as well as provide more details on the sheet.

Assuming the drop down is in A1, you pass the selection to the macro like so:

Code:
'define a string variable that will be used to hold the cell value
Dim strName as String

'set the variable equal to the current cell selectio
strName = Sheet1.Range("A1").Value

'pass the variable to the worksheet object so that paste the results to correct sheet
Range("A2:B10").Copy worksheets(strName).Range("A1")

This is just a basic example but may be enough to get you going.
You would need to include code to check for existence of the worksheet, as well other potential errors that may need to be trapped.
 
Last edited:
Top