+ Reply to Thread
Results 1 to 4 of 4

Macro to select worksheet based on cell value and then return data to diff worksheet

  1. #1
    Registered User
    Join Date
    04-18-2013
    Location
    Lexington
    MS-Off Ver
    Excel 2010
    Posts
    3

    Macro to select worksheet based on cell value and then return data to diff worksheet

    I'm new to VBA and would like to run a macro that selects the corresponding worksheet based on a cell value and then returns data within that worksheet to a "summary" worksheet.

    I have attached the spreadsheet. So if the year is 2012, i want to select the 2012 tab, then return the schedule that corresponds to Alabama for the 2012 year. I might be making this harder than it needs to be but I dont want to have to write long ifstatements.

    Thanks
    Attached Files Attached Files
    Last edited by clnossok; 04-21-2013 at 07:34 PM.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Macro to select worksheet based on cell value and then return data to diff worksheet

    See if this helps...

    CFB Predictor - ASRev.xlsm
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Registered User
    Join Date
    04-18-2013
    Location
    Lexington
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro to select worksheet based on cell value and then return data to diff worksheet

    Thanks! Will this also work if I change the year as long as the year is one of the worksheets?

  4. #4
    Registered User
    Join Date
    04-18-2013
    Location
    Lexington
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro to select worksheet based on cell value and then return data to diff worksheet

    How do i edit the macro to select the corresponding sheet when the cell value changes? Like if the year is set to 2011, I want to select the sheet named 2011, if the year is 2013, select the sheet named 2013. But then select the same data on each sheet since its in the same cell.

    I have attached the spreadsheet. When i change the team it doesnt automatically change. I have to retype in the year for it to change. Ideally like the schedule to update automatically when i change the year and when i change the team

    Thanks for the help!
    Attached Files Attached Files
    Last edited by clnossok; 04-22-2013 at 09:16 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1