Button to change sheet and select a value from list

M.Bachrach

New Member
Joined
Feb 25, 2011
Messages
1
Hi everybody!
I would like to create buttons for the index page of my project that would bring the reader to a certain sheet and that automatically selects from a drop down list (data validation) depending on the country of interest.

The charts in the sheet are created retrieving data from databset with Vlookup's and change depending on country selected.

I know how to do the first step, but was not able to find a solution to the second one (code for the drop down menu).

Anybody can help?I cannot attach the file because data is confidential but the drop down list cell is D5 in the sheet "OpCo" (the one that needs to be activated).

thank you!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
You could try

Code:
Sub change_sheet()
    Dim sheetref As Variant
    sheetref = Sheets("OpCo").Range("D5").Value
        Sheets(sheetref).Activate
End Sub

and then simply attach it to a button. If you want it to automatically take you to the sheet once you choose the option for the dropdown menu then try this in the the OpCo sheet

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim sheetref As Variant
    If Target.Address = "$D$5" Then
         sheetref = Sheets("OpCo").Range("D5").Value
            Sheets(sheetref).Activate
    End If

End Sub

HTH
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,451
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top