VB use of field text to select & execute macro

dlbarrett

New Member
Joined
Dec 22, 2011
Messages
1
I need to select and unhide a sheet based on the the text that is input and stored in a spreadsheet. I have four options that will be stored in a sheet called MENU. The options are: Automotive, Industrial, Life_Sciences, Electronics.


Based on the field selection in the cell h9 I want to execute a macro to unhide the appropriate sheet.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Use this and and replace to suit yours needs.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$2" Then Exit Sub
 
    Application.ScreenUpdating = False
    Range("A1").Select
    Worksheets("PCAP 3.31").Visible = False
    Worksheets("PCAP 6.30").Visible = False
    Worksheets("PCAP 9.30").Visible = False
    Worksheets("PCAP 12.31").Visible = False
    Columns("F:L").Hidden = False
 
    Select Case Target.Value
        Case "First Quarter"
            Worksheets("PCAP 3.31").Visible = True
            Columns("F:K").Hidden = True
 
        Case "Second Quarter"
            Worksheets("PCAP 6.30").Visible = True
            Columns("H:K").Hidden = True
 
        Case "Third Quarter"
            Worksheets("PCAP 9.30").Visible = True
            Columns("J:K").Hidden = True
 
        Case "Fourth Quarter"
            Worksheets("PCAP 12.31").Visible = True
    End Select
 
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,099
Members
448,548
Latest member
harryls

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