+ Reply to Thread
Results 1 to 2 of 2

When a selection is made from a drop down then the sheet is switched to a different sheet

  1. #1
    Registered User
    Join Date
    03-12-2020
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    7

    When a selection is made from a drop down then the sheet is switched to a different sheet

    I can't seem to figure out why this doesn't work. When I choose the drop down selection that should activate or trigger the vba code, nothing happens. I have the below code under Sheet1 which is named (2Weeks) (...right click and pasted in view code window for that sheet). That’s all the code I have… no modules. I have (General) for the Object choice and (ListBox1_Change) (which is the drop down list in cell B4), for the Procedure. B4 is a cell with a drop down list with a bunch of date ranges like these two… (08/01/2024 - 08/18/2024, 11/11/2024 - 12/01/2024). By the way, must I have a combo box instead of a list box to make this code work? The two date ranges listed above, if selected, should change to a different sheet, Sheet2, which is named 3Weeks, from the current one. And when switched to the other sheet, the user would be on cell B4 of the new sheet. The two sheet names are sheet1=2Weeks and sheet2=3Weeks. Would anyone be able to fix this or come up with a totally different code to accomplish this? Also, am I allowed to have a comma in between the dates so if the user chooses either date it triggers the vba code? Can there be more than two dates to trigger the VBA? If so, would they be separated by commas in the code?

    Please Login or Register  to view this content.
    The B4 cell drop down references L3:L23 and looks like this:
    07/15/2024 - 07/31/2024
    08/01/2024 - 08/18/2024
    08/19/2024 - 09/01/2024
    09/02/2024 - 09/15/2024
    09/16/2024 - 09/29/2024
    09/30/2024 - 10/13/2024
    10/14/2024 - 10/27/2024
    10/28/2024 - 11/10/2024
    11/11/2024 - 12/01/2024
    11/30/2024 - 12/13/2024
    12/14/2024 - 12/31/2024 …etc.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,934

    Re: When a selection is made from a drop down then the sheet is switched to a different sh

    You need to attach a sample file per the yellow banner at the top of the window.
    ByVal Target As Range is not part of the VBA listbox procedure declaration. You can't just add it on your own.
    The syntax of your IF..Then has many problems:
    ...attach a sample file.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 05-31-2016, 01:55 PM
  2. Replies: 5
    Last Post: 07-22-2014, 06:29 AM
  3. [SOLVED] create hyperlink to another sheet when specific selection is made on a dropdown
    By FlyFisherman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-17-2013, 11:32 AM
  4. Replies: 0
    Last Post: 05-06-2013, 08:33 AM
  5. [SOLVED] Automatically open a different sheet within the workbook when a selection is made
    By clovelly in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 10-16-2012, 10:53 PM
  6. Copy/Paste Data from Row to Another Sheet if Selection Made from Drop down Menu
    By bufb45 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-13-2012, 12:47 PM
  7. how to check if user has made a selection on the sheet
    By chawla12amit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2005, 03:51 PM

Tags for this Thread

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