LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default combining two short VBA scripts from two buttons

learning VBA and Macros in Excel, so forgive my newbie-ness.

I have two button forms, each with it's own macro.

Sub Button8_Click()
Range("J2:Q2").Select
Selection.EntireColumn.Hidden = True
End Sub

Sub Button9_Click()
Range("I2:R2").Select
Selection.EntireColumn.Hidden = False
Range("G2").Select
End Sub


One button(8) hides columns, the other button(9) reveals them. Is
there a simple bit of code that will allow me to combine these
functions onto one button? The macro that runs on click would depend on
the state of the sheet. If columns are hidden, the button would run
the "unhide" macro; if columns are unhidden, the button would run the
"hide" macro.

Also, as a nice touch, the button text would change to reflect
appropriate pending action.

This is, I guess, a basic on/off situation, but I can't figure it out.
:(

 
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
delete scripts AND Excel Worksheet Functions 1 March 20th 09 01:16 PM
Forumlas or scripts? Gor_yee Excel Discussion (Misc queries) 0 October 16th 06 01:53 PM
SQL Scripts in Excel markus Excel Discussion (Misc queries) 1 October 13th 06 12:39 PM
SQL scripts and ODBC James McDowell[_2_] Excel Programming 0 January 13th 06 10:38 PM
Macintosh and VB Scripts ccoverne Excel Programming 2 November 29th 04 09:11 PM


All times are GMT +1. The time now is 11:43 PM.

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

About Us

"It's about Microsoft Excel"