ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Compile error (https://www.excelbanter.com/excel-discussion-misc-queries/252909-compile-error.html)

Learning VBA

Compile error
 
I am getting acompile error end with without with on this code.

With Me.Range("B190")
If .Value 0 Then
ActiveSheet.Tab.ColorIndex = 6
Else
If .Value < 0 Then
ActiveSheet.Tab.ColorIndex = 3
Else
ActiveSheet.Tab.ColorIndex = 0
End If
End With

Per Jessen

Compile error
 
You miss a 'End If' statement

With Me.Range("B190")
If .Value 0 Then
ActiveSheet.Tab.ColorIndex = 6
Else
If .Value < 0 Then
ActiveSheet.Tab.ColorIndex = 3
End If ' <=====
Else
ActiveSheet.Tab.ColorIndex = 0
End If
End With

Regards,
Per

"Learning VBA" skrev i meddelelsen
...
I am getting acompile error end with without with on this code.

With Me.Range("B190")
If .Value 0 Then
ActiveSheet.Tab.ColorIndex = 6
Else
If .Value < 0 Then
ActiveSheet.Tab.ColorIndex = 3
Else
ActiveSheet.Tab.ColorIndex = 0
End If
End With



Dave Peterson

Compile error
 
Maybe...

With Me.Range("B190")
If .Value 0 Then
ActiveSheet.Tab.ColorIndex = 6
Else
If .Value < 0 Then
ActiveSheet.Tab.ColorIndex = 3
Else
ActiveSheet.Tab.ColorIndex = 0
End If
end if
End With

Learning VBA wrote:

I am getting acompile error end with without with on this code.

With Me.Range("B190")
If .Value 0 Then
ActiveSheet.Tab.ColorIndex = 6
Else
If .Value < 0 Then
ActiveSheet.Tab.ColorIndex = 3
Else
ActiveSheet.Tab.ColorIndex = 0
End If
End With


--

Dave Peterson

Learning VBA

Compile error
 
Thank you Dave
That appears to have done what I want it to.



"Dave Peterson" wrote in message
...
Maybe...

With Me.Range("B190")
If .Value 0 Then
ActiveSheet.Tab.ColorIndex = 6
Else
If .Value < 0 Then
ActiveSheet.Tab.ColorIndex = 3
Else
ActiveSheet.Tab.ColorIndex = 0
End If
end if
End With

Learning VBA wrote:

I am getting acompile error end with without with on this code.

With Me.Range("B190")
If .Value 0 Then
ActiveSheet.Tab.ColorIndex = 6
Else
If .Value < 0 Then
ActiveSheet.Tab.ColorIndex = 3
Else
ActiveSheet.Tab.ColorIndex = 0
End If
End With


--

Dave Peterson




All times are GMT +1. The time now is 05:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com