View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ellmcg ellmcg is offline
external usenet poster
 
Posts: 2
Default If Then statement in macro gone wrong

Thanks! I'd tried tweaking the layout in so many ways, but hadn't been able
to get the right one...


"JMB" wrote:

Since VBA allows you to put If/Then on the same line, the Else is being
treated as its own statement.

If ActiveCell = "" Then
Selection.Rows.Hidden = True
Elseif ActiveCell = "Blah Blah Blah" Then
Selection.Rows.RowHeight = 25.5
Else: Selection.Rows.AutoFit
End If

"ellmcg" wrote:

Can anyone tell me whats wrong with the below? It keeps returning the
message "Compile Error: Else without If", when it gets to 'ActiveCell', on
the 2nd line...

If ActiveCell = "" Then Selection.Rows.Hidden = True
Else: If ActiveCell = "Blah Blah Blah" Then Selection.Rows.RowHeight =
25.5
Else: Selection.Rows.AutoFit
End If