Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Toggle Command Button to Show/Hide the Shaded Headers Columns

How do I code a Toggle Command Button to Show or Hide all Columns
which
headers are shaded ?

Thank you,

Celeste
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Toggle Command Button to Show/Hide the Shaded Headers Columns

Not sure where your commandbutton will be located... but here is some code
you can apply to it...

If you embed a commandbutton on the worksheet, the first thing that should
pop up is what macro you want to assign to it.

Here is what I would do:
1. Copy the macro below
2. Open your Excel file
3. Hit ALT + F11 to open the VBE
4. Insert a new module
5. Paste the code (shown below)
6. Go to the worksheet you want this commandbutton on
7. Insert/Embed your command button
8. Use the pop up to assign it to the new macro

Mark Ivey


Sub HideColumnsWithShadedHeaderCells()
Dim myRange As Range

For i = 1 To 256

Set myRange = Cells(1, i)

If myRange.Interior.ColorIndex < xlNone Then
myRange.EntireColumn.Hidden = True
End If
Next

End Sub


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
Command Button to show/hide a different worksheet Marilyn Excel Discussion (Misc queries) 1 April 22nd 09 03:37 AM
Toggle Button in Ribbon to Hide/Show Built-in Tabs Don[_30_] Excel Programming 0 March 27th 08 01:17 PM
using a toggle button to show or hide information in several cells hanson Excel Worksheet Functions 3 December 7th 07 11:16 PM
Using Command Button to Hide Columns in another worksheet AndrewJ[_2_] Excel Programming 2 September 14th 06 05:06 AM
hide and show columns using one control button dreamkeeper Excel Programming 8 March 3rd 06 04:16 AM


All times are GMT +1. The time now is 01:26 PM.

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"