View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas[_2_] Gary Keramidas[_2_] is offline
external usenet poster
 
Posts: 364
Default macro to hide # of columns based on value

not much info to work with, i used cell T1 on sheet1 as the value for the
first column

Sub test()
Dim colnum As Long
Dim ws As Worksheet
Set ws = Worksheets("sheet1")
colnum = ws.Range("t1").Value
With ws
.Columns(colnum).Resize(, 18 - colnum).EntireColumn.Hidden = True
End With
End Sub

--


Gary Keramidas


"Graeme" wrote in message
...
I am trying to write a macro which will hide certain columns based upon the
value of a cell. For example, if cell value = 1, hide columns A:Q, if
value
= 2, hide columns B:Q, if value = 3, hide C:Q and so on. Is there a quick
way of doing this. Thank you.