+ Reply to Thread
Results 1 to 6 of 6

Sheet Change when Value is Selected

Hybrid View

  1. #1
    Registered User
    Join Date
    07-11-2023
    Location
    USA
    MS-Off Ver
    2008
    Posts
    7

    Sheet Change when Value is Selected

    Hello,

    I have a data validation list / drop down menu of dates in mmmm d format. I am trying to code the workbook so that when a date is selected, you are taken to the sheet with the matching date name. For example, if I select June 29, I want to automatically be taken to the sheet labeled June 29.

    This is the code I currently have:
    Private Sub Worksheet_Change(ByVal Target As Range)
        On Error Resume Next
        If Not (Application.Intersect(Range("B1"), Target) Is Nothing) Then _
            This Workbook.Sheets(Target.Value).Activate
    End Sub
    B1 is the drop down list selection. When I debug, the first line errors. What am I doing wrong?

    DEMO.xlsm
    Last edited by goldyf_ishy; 07-11-2023 at 12:57 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,673

    Re: Sheet Change when Value is Selected

    When asking for help with a VBA error, always give us the error number and error description.

    The error must not be on the first line, because there's nothing wrong with the first line.

    ThisWorkbook has to be all one word. That will give you a compile error.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    07-11-2023
    Location
    USA
    MS-Off Ver
    2008
    Posts
    7

    Re: Sheet Change when Value is Selected

    Thank you for your response. I am no longer receiving a debug error after fixing ThisWorkbook, however the function is still not working. Nothing happens when a date is selected in the drop down list.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Sheet Change when Value is Selected

    Hi goldyf_ishy,

    The thing is.. the drop down actually contains a date made to look like just month day (target.value is 2023-07-06 for july 6).

    Try:

    If Not (Application.Intersect(Range("B1"), Target) Is Nothing) Then _
            ThisWorkbook.Sheets(Format(Target.Value, "mmmm d")).Activate
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  5. #5
    Registered User
    Join Date
    07-11-2023
    Location
    USA
    MS-Off Ver
    2008
    Posts
    7

    Re: Sheet Change when Value is Selected

    Thank you so much! This fixed it!

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Sheet Change when Value is Selected

    Glad to hear it
    Please don't forget to mark the thread as Solved if you are satisfied? Thanks!

+ 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. [SOLVED] Change formula to refer to selected sheet
    By josephteh in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-10-2023, 10:53 PM
  2. [SOLVED] Balance change over selected periods at a selected % rate
    By vill in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-22-2017, 04:58 PM
  3. Change Selected Cell Colour ...only whilst selected
    By mrgrotey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2017, 07:40 AM
  4. Replies: 4
    Last Post: 09-16-2013, 04:23 PM
  5. [SOLVED] Trying to copy selected items from sheet to listbox then selected back to sheet
    By BigWes1960 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 03-14-2013, 03:27 PM
  6. Replies: 0
    Last Post: 09-05-2005, 10:05 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