Macro Buttons

SAS

Can't get enough of FH
Joined
Dec 23, 2003
Messages
1,004
I've placed a toggle button on a spreadsheet to hide / unhide data. The idea is to show the data to copy and paste results in and give the option to hide the unneeded parts before printing.

Is there anyway to ensure upon loading the spreadsheet the button will default to the unhide position? :/
 

Gat_Decor

Fledgling Freddie
Joined
Aug 7, 2004
Messages
394
Code:
Private Sub Worksheet_Activate()
ToggleButton1.Value = False

End Sub

all depends how you've coded the togglebutton i.e. if its state is false then the data is unhidden
 

Gat_Decor

Fledgling Freddie
Joined
Aug 7, 2004
Messages
394
Actually, looking at it again what i posted was bollox it doesn't work..
i'm stumped, maybe teh excel Meister Joooopitus has an idea?
 

JingleBells

FH is my second home
Joined
Mar 25, 2004
Messages
2,224
Try:
Code:
Private Sub CommandButton1_Click()
Rows("10:15").Select
Selection.EntireRow.Hidden = Not Selection.EntireRow.Hidden
End Sub
for the click event on the button.
 

SAS

Can't get enough of FH
Joined
Dec 23, 2003
Messages
1,004
No joy :(

Spreadsheet is here: (http://www.grenney.co.uk/files/macro April - Bonus Calculator v2 - Team Performance.xls) (to unlock, password is birdflu).

Everything looks logical. Button code works ok, but if I change any statments the columns are always hidden if the "hide" option was selected when the worksheet was closed. Can't seem to force it to be unhid when the worksheet is opened :/

I'm probably missing something obvious mind as I'm a newbie to marcos.

Jup suggested the Workbook_open() option which I've added but does not seem to run. :/
 

Gat_Decor

Fledgling Freddie
Joined
Aug 7, 2004
Messages
394
This is what i had in mine to try and get round the 'hidden' becoming 'unhidden' but as i said earlier and you've now tested as Jupitus suggested, it doesn't work.


Code:
Private Sub Workbook_Open()
   Columns("H:I").Select   <----- my test columns
    Selection.EntireColumn.Hidden = False

End Sub
 

MYstIC G

Official Licensed Lump of Coal™ Distributor
Staff member
Moderator
FH Subscriber
Joined
Dec 22, 2003
Messages
12,391
Code:
Sub Workbook_Open()

    Columns("A:IV").Hidden = False

End Sub

Obviously you can change the columns to selected ones if you prefer.

http://support.microsoft.com/?kbid=265113 for more info on WorkBook_Open

You need to set ya Macro security level to Medium really as well.
 

SAS

Can't get enough of FH
Joined
Dec 23, 2003
Messages
1,004
Cheers guys will try the code you pasted when I get some free time.
 

Rubric

Part of the furniture
Joined
Dec 22, 2003
Messages
2,145
I'm useless with code but i guess the problem stems from closing the worksheet and it being saved with everything exposed.

If the columns only need revealing when printing why not create a print button and record a macro the unhides the colums prints the document and then hides them again?

Or have a close macro button that ensures that the columns are hidden before exiting and saving.
 

Users who are viewing this thread

Top Bottom