Alenn G'Kar
Alenn G'Kar

Reputation: 123

VBA Hide/Unhide Button

Hello I'd like to use several VBA codes, shorter = better, I have this:

Sub less0()
Security.UnlockS
    Range("15:29").Rows.Hidden = True
Security.LockS
End Sub

Sub more0()
Security.UnlockS
    Range("15:29").Rows.Hidden = False
Security.LockS
End Sub

But now I have one button and it need to be dynamical tryed this...

Sub less001()
Security.UnlockS
Dim what As String: what = Range("18:26").Rows.Hidden
    If what = True Then what = False: If what = True Then Exit Sub
    If what = False Then what = True: If what = False Then Exit Sub
Security.LockS
End Sub 

(also lock problem)

But it's not working and no debug /o\

Pls I have seen some similar codes here, but they are extremly complicated, I feel that this is a simple case.

Thank you for your time.

Upvotes: 0

Views: 1128

Answers (1)

Tim Williams
Tim Williams

Reputation: 166126

Sub less001()
    Security.UnlockS
    With Range("18:26").Rows
        .Hidden = Not .Hidden
    End with
    Security.LockS
End Sub 

Upvotes: 2

Related Questions