View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default If - End if problem

Papa J

The indentations shouldn't make a difference.

If you look at what you posted, and what I posted, you will see the difference
in line 3 of mine versus Line 2 of yours:

PJ: Else: If locale = "L" Then Selection.Interior.ColorIndex = 6

RR: ElseIf locale = "L" Then Selection.Interior.ColorIndex = 6

As Richard pointed out, you will find it easier, in the long run, to not use
the ":" at all to combine lines, but rather to put the information on separate
lines.

Best wishes,
--ron



On Tue, 18 Dec 2007 12:11:01 -0800, Papa Jonah
wrote:

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


--ron