简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM