Results 1 to 2 of 2

Thread: indirect reference in macro to select different worksheets

  1. #1

    indirect reference in macro to select different worksheets

    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    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:

    '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 by Palmetto; 2013-02-23 at 05:48 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts