View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Papa Jonah Papa Jonah is offline
external usenet poster
 
Posts: 148
Default If - End if problem

Apparently, after cutting and pasting yours, the only difference I see is the
indentation of yours between If and End if - but yours works.
Thanks

"Ron Rosenfeld" wrote:

On Mon, 17 Dec 2007 14:44:34 -0800, Papa Jonah
wrote:

Rick,
I have tried that. However, when I use "ElseIf" I still get a compile error
"else without if" and highlights "ElseIf locale = "L" then"

This is what I have currently:
If locale = "P" Then Selection.Interior.ColorIndex = 3
Else: If locale = "L" Then Selection.Interior.ColorIndex = 6
Else: Selection.Interior.ColorIndex = 9
End If

When I run the macro, I am currently getting a "Compile Error - Else without
If" with the first "Else:" highlighted.

I don't see the difference in what I have tried and what has been suggested
- but it still isn't working.
Thanks for bearing with me.

Papa J



This:

If locale = "P" Then
Selection.Interior.ColorIndex = 3
ElseIf locale = "L" Then Selection.Interior.ColorIndex = 6
Else: Selection.Interior.ColorIndex = 9
End If

or this:

If locale = "P" Then
Selection.Interior.ColorIndex = 3
ElseIf locale = "L" Then Selection.Interior.ColorIndex = 6
Else
Selection.Interior.ColorIndex = 9
End If


Both work OK here.
--ron