View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Hide unhide non-contiguous columns

Hi,

This makes it into a toggle of hide/unhide

If Not Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden Then
Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden = True
Else
Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden = False
End If

Mike

"Saintsman" wrote:

How do I unhide them using the same control?

"Mike H" wrote:

Try this

If Not Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden Then
Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden = True
End If

Mike

"Saintsman" wrote:

I use the following code to hide/unhide a range of cells using a tick box
With Columns("O:W")
.Hidden = Not .Hidden
End With

I want to do exactly the same for columns G,J,P,R ie if they are hidden then
unhide them, if they are not hidden then hide them
Any help appreciated