Hi, I'm trying to code a button to hide and show data in cells H5:I9 (MS Excel 2002)
Here's the code:
[CODE=vb]Sub Button21_Click( )
If Range("H5:H9"). NumberFormat = "General" And Range("I5:I9"). NumberFormat = "0.00%" Then Range("H5:I9"). SelectSelection .NumberFormat = ";;;"
Else: If Range("H5:I9"). NumberFormat = ";;;" Then Range("H5:I9"). Select
Selection.Numbe rFormat = "General"
Range("I5:I9"). Select
Selection.Numbe rFormat = "0.00%"
End Sub[/CODE]
It appears to be ok (messy I know, but valid) yet I get a compiler error saying "Else without If".
What's wrong? It's driving me nuts!
Here's the code:
[CODE=vb]Sub Button21_Click( )
If Range("H5:H9"). NumberFormat = "General" And Range("I5:I9"). NumberFormat = "0.00%" Then Range("H5:I9"). SelectSelection .NumberFormat = ";;;"
Else: If Range("H5:I9"). NumberFormat = ";;;" Then Range("H5:I9"). Select
Selection.Numbe rFormat = "General"
Range("I5:I9"). Select
Selection.Numbe rFormat = "0.00%"
End Sub[/CODE]
It appears to be ok (messy I know, but valid) yet I get a compiler error saying "Else without If".
What's wrong? It's driving me nuts!
Comment