Autohide & Variables

JaymzVXR

New Member
Joined
Nov 25, 2013
Messages
1
Hi!

Love this forums, its been a great help in the past as reference but first time I've needed to ask something that wasn't already available.

Ive a spreadsheet of data with headers and only some of the cells are filled. These are filled with numbers which represent processes.

I'm trying to create a macro that if in B1 you enter 1,2, etc. it will show the columns that include these numbers but hide the others. I've tried this but had no such luck

Private Sub Worksheet_Change(ByVal Target As Range)
Columns("C:AG").Hidden = Range("B1").Value = "06"
End Sub


Thanks in advance!
 

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.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 1 And Target.Column = 2 Then
        Columns.Hidden = False
        Columns(Target.Value).Hidden = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,790
Messages
6,174,594
Members
452,574
Latest member
hang_and_bang

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