Alex Piotto
Board Regular
- Joined
- Jul 5, 2016
- Messages
- 82
- Office Version
- 2007
- Platform
- Windows
Hi!
I have got two command buttons overlapping.
In the script below, CommandButton1 will hide the zero's rows, and CommandButton2 will show them again.
And they will hide and show each other too.
The hiding zeros part is OK.
Quite simple I can say... BUT....
... BUT... the buttons will hide only if I click somewhere on the sheet.
Why is that happening and what can I do to avoid it?
I have got two command buttons overlapping.
In the script below, CommandButton1 will hide the zero's rows, and CommandButton2 will show them again.
And they will hide and show each other too.
The hiding zeros part is OK.
Quite simple I can say... BUT....
VBA Code:
'HIDING ZERO ROWS
ActiveSheet.Shapes("CommandButton2").Visible = True
ActiveSheet.Shapes("CommandButton1").Visible = False
Dim cell As Range
For Each cell In Range("K2:K200")
If Not IsEmpty(cell) Then
If cell.Value <> "" And cell.Value = 0 Then
cell.EntireRow.Hidden = True
End If
End If
Next
VBA Code:
'SHOW ALL ROWS
ActiveSheet.Shapes("CommandButton1").Visible = True
ActiveSheet.Shapes("CommandButton2").Visible = False
Dim cell As Range
For Each cell In Range("K2:K200")
cell.EntireRow.Hidden = False
Next
... BUT... the buttons will hide only if I click somewhere on the sheet.
Why is that happening and what can I do to avoid it?