Hidden Columns unhiding when dropdown is selected

gymnst920

New Member
Joined
May 1, 2017
Messages
1
I have a worksheet that I have created that unhides columns based on what is selected in a dropdown. My problem is that when those hidden columns appear and I select a value from the drop down in that previously hidden column all the columns that I want to stay hidden appear. I have tried updating the "Lotus compatibility" settings and that doesn't seem to work. A small portion of my code looks like below:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Column = 7 And Target.Row = 3 And Target.Value = "1" Then
Application.Columns("I:M").Select
Application.Selection.EntireColumn.Hidden = True
Else
Application.Columns("I:M").Select
Application.Selection.EntireColumn.Hidden = False


If Target.Column = 7 And Target.Row = 3 And Target.Value = "2" Then
Application.Columns("J:M").Select
Application.Selection.EntireColumn.Hidden = True
Else
Application.Columns("J:M").Select
Application.Selection.EntireColumn.Hidden = False

I'm probably doing this whole forum thing wrong so I'm sorry! Very new to this and am pretty lost!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You should start with :
Code:
Columns("I:M").EntireColumn.Hidden=False

so now we are sure everything is unhidden. Then you should have :

Code:
If Target.Column=7 And Target.Row=3 Then
    If Target.Value=1 Then
        .... do your stuff
    ElseIf Target.Value=2 Then
        ... do your stuff
    ElseIf ....

Hope this is what you are looking for!
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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