我的问题是,如何让这个脚本隐藏列?显然,列不适用于数字,但使用字母和某种方式脚本将不接受像“btn_E_3_H”这样的输入。
Sub ShowHideRows()
Dim arr
'split the calling button name into an array
' (array will be zero-based)
arr = Split(Application.Caller, "_")
'**EDIT** check array is expected size...
If UBound(arr) <> 3 Then Exit Sub
If IsNumeric(arr(1)) and IsNumeric(arr(2)) Then
With Me 'if the code is in the sheet module, else "ActiveSheet"
.Unprotect Password:="abc"
'arr(1) determines start row
'arr(2) determines # of rows
'arr(3) determines if rows are hidden or not
.Cells(arr(1), 1).Resize(arr(2), 1).EntireRow.Hidden = (arr(3) = "H")
.Protect Password:="abc"
End With
End If
End Sub
感谢您的评论