dear all,
could you please help me to correctly perform the following code:
Private Sub CommandButton1_Click()
If Range("E2").Value = "1" Then
Rows("50:102").EntireRow.Hidden = True
End If
If Range("E2").Value = "2" Then
Rows("32:105").EntireRow.Hidden = False
End If
If Range("E2").Value = "2" Then
Rows("68:102").EntireRow.Hidden = True
End If
If Range("E2").Value = "3" Then
Rows("86:105").EntireRow.Hidden = False
End If
If Range("E2").Value = "3" Then
Rows("86:102").EntireRow.Hidden = True
End If
If Range("E2").Value = "4" Then
Rows("32:105").EntireRow.Hidden = False
End If
If Range("E2").Value > "4" Then
Rows("32:105").EntireRow.Hidden = True
End If
If Range("E2").Value < "1" Then
Rows("32:105").EntireRow.Hidden = True
End If
If Range("E2").Value < 1 Or Range("C3").Value > 4 Then
Range("32:105").EntireRow.Hidden = False
End If
End Sub
When excel opened, cell E2 is equal to zero and range 32:105 is hidden. when is put E2 equals to 0 it opened all cells but what I want it's not opening nothing when it's below 1 and greather than 4. For instance when I put E2 equals to 1 an execute button it does not open range 32:50. It seems it is not working because I am not following a certain path...
thank you
could you please help me to correctly perform the following code:
Private Sub CommandButton1_Click()
If Range("E2").Value = "1" Then
Rows("50:102").EntireRow.Hidden = True
End If
If Range("E2").Value = "2" Then
Rows("32:105").EntireRow.Hidden = False
End If
If Range("E2").Value = "2" Then
Rows("68:102").EntireRow.Hidden = True
End If
If Range("E2").Value = "3" Then
Rows("86:105").EntireRow.Hidden = False
End If
If Range("E2").Value = "3" Then
Rows("86:102").EntireRow.Hidden = True
End If
If Range("E2").Value = "4" Then
Rows("32:105").EntireRow.Hidden = False
End If
If Range("E2").Value > "4" Then
Rows("32:105").EntireRow.Hidden = True
End If
If Range("E2").Value < "1" Then
Rows("32:105").EntireRow.Hidden = True
End If
If Range("E2").Value < 1 Or Range("C3").Value > 4 Then
Range("32:105").EntireRow.Hidden = False
End If
End Sub
When excel opened, cell E2 is equal to zero and range 32:105 is hidden. when is put E2 equals to 0 it opened all cells but what I want it's not opening nothing when it's below 1 and greather than 4. For instance when I put E2 equals to 1 an execute button it does not open range 32:50. It seems it is not working because I am not following a certain path...
thank you