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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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