VBA Help with coding to select from list then hide/show columns

Chris_86

New Member
Joined
Dec 9, 2012
Messages
18
Office Version
  1. 2013
Platform
  1. Windows
Hi All,

I am attempting to select from a drop down list and based on the selection I wish to hide the columns that are not relevant.
This is the code that I'm using however am not getting any changes what so ever.
Any suggestions would be amazing :) thank you.

VBA Code:
Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.Unprotect

ActiveSheet.Activate
If Not Application.Intersect(Range("M3"), Range(Target.Address)) Is Nothing Then
        Select Case Target.Value
        Case Is = "Show_All": Columns("I:L").EntireColumn.Hidden = False
                            Columns("E:H").EntireColumn.Hidden = False
        Case Is = "Powerlink": Columns("AK:AV").EntireColumn.Hidden = False
                           Columns("AG:AJ").EntireColumn.Hidden = True
        Case Is = "Transgrid": Columns("AG:AJ").EntireColumn.Hidden = False
                           Columns("AK:AV").EntireColumn.Hidden = True
        Case Is = "Electranet": Columns("I:L").EntireColumn.Hidden = False
                           Columns("E:H").EntireColumn.Hidden = False
        End Select
End If

ActiveSheet.Protect

End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,215,575
Messages
6,125,618
Members
449,238
Latest member
wcbyers

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