Hide Shows Columns to right of drop-down

The Animal

Active Member
Joined
May 26, 2011
Messages
449
Hi.
I want to link a macro to a Drop-down to Hide 4 columns to the right of the column the drop-down is found and then to Unhide again. It will act like a toggle button rather than using a button I want to use a drop-down and assign the macro to the relevant source heading.
The two source headings in the drop-down are 'Show Data' which will unhide the 4 columns to the right of the column that drop-down column is found and "Hide Data" which will then hide them again when selected.
Any help with the macros would be great
Thanks Stephen
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi again.
I just re-read and maybe I need to add a little explanation.
So if I have a drop-down in column "O1" with the two source headings as "Show Data" and "Hide Data" then I want columns P:S to Hide and then if I select the "Show Data" I want P:S to unhide.
I know how to assign the macro to the drop-down source heading I just cannot work out the Hide and Unhide macro that I need to assign.
I will need to copy and paste this drop-down into multiple cells so I need the macro to be using a code that hides and unhides 4 columns to the left rather than specific column codes i.e "hide columns P:S.
Thanks again Stephen
 
Upvote 0
Try this in the sheet module.
Change the cells Range("A1,F1,K1,P1")) to match your drop down cells.

Howard

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub

Dim isect As Range
Set isect = Intersect(Target, Range("A1,F1,K1,P1"))

If Not isect Is Nothing Then

    If Target.Value = "Hide Data" Then

        Target.Offset(0, 1).Resize(, 4).EntireColumn.Hidden = True

      Else

        Target.Offset(0, 1).Resize(, 4).EntireColumn.Hidden = False

    End If
    
End If
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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