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/252908-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

Don Guillett

Compile error
 
right click sheet tabview codeinsert this. Now when you change the cell
the tab color will automatically change. This even accounts for someone
touching the "dreaded space bar"

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < Me.Range("b190").Address Then Exit Sub

If Len(Application.Trim(Target)) < 1 Then
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If

Select Case Target
Case Is 0: c = 6
Case Is < 0: c = 3
Case Else: c = xlColorIndexNone
End Select
Me.Tab.ColorIndex = c
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Learning VBA" wrote in message
...
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




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

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