Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Hide unhide non-contiguous columns

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Hide unhide non-contiguous columns

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Hide unhide non-contiguous columns

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Hide unhide non-contiguous columns

Sub togglehiddencolumns()
Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden = Not _
Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Saintsman" wrote in message
...
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Hide unhide non-contiguous columns

Thanks to all of you - lots of options for me to pick from

Saintsman

"Don Guillett" wrote:

OR
Sub togglehiddencolumns()
With Range("G:G,J:J,P:P,R:R").EntireColumn
.Hidden = Not .Hidden
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
Sub togglehiddencolumns()
Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden = Not _
Range("G:G,J:J,P:P,R:R").EntireColumn.Hidden
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Saintsman" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide/Unhide columns using button on top over relevant columns [email protected] Excel Discussion (Misc queries) 1 March 7th 07 09:24 PM
I set up a macro to hide/unhide columns. It hides more columns Lori Excel Programming 1 September 6th 06 04:08 PM
Hide non-contiguous columns BEEJAY Excel Programming 2 May 23rd 06 01:25 PM
Hide and unhide columns Frederic Excel Programming 2 September 14th 05 09:53 PM
hide / unhide columns appeng Excel Programming 1 March 25th 05 10:16 PM


All times are GMT +1. The time now is 04:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"