[MSVB in Excel] Showing and Hiding Rows with a button

Sic

Sic

Soldato
Joined
9 Nov 2004
Posts
15,365
Location
SO16
right, i've NEVER used MSVB before, and it's going to show when you see this...but i'm trying to make a macro to hide certain rows in excel when a button is clicked. i've got this so far: (i know it's probably completely retarded)

Code:
Sub Button1_Click()

    Rows("5:7").Select
    If Selection.EntireRow.Hidden = False Then
    Selection.EntireRow.Hidden = True
    End If
End Sub
Sub Button2_Click()

    Rows("5:7").Select
    If Selection.EntireRow.Hidden = True Then
    Selection.EntireRow.Hidden = False
    End If
End Sub

but i'm completely at a loss. can anyone give me a bit of help for this please, as my excel sheet's going to be all messy if i can't do this :(

thank you :)
 
i dont quite remember how to do it. but if you record a macro doing what you want it to do and then look at the code for the macro and copy it to your button i seem to rmemeber that how i used to figure it out
 
yeah, but the problem i have is i need the button to perform 2 separate functions. if the rows are hidden, i need the button to show them, if the cells are shown, i need the button to hide them. i thought that's what i was doing, but i think i'm a bit wrong as it's not working :o
 
Back
Top Bottom