If Then statement in macro gone wrong

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Thanks! I'd tried tweaking the layout in so many ways, but hadn't been able
to get the right one...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top