Entrerri99
New Member
- Joined
- Mar 9, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Sorry, this one is driving me crazy. I have the macro below that I'm trying to use to change the color of cells A:M based on the value in column C, however I'm getting a mismatch on this line:
Set CurrentStatus = ActiveSheet.Cells(Rng.Row, StatusColumn).Value
I've done a message box on the ActiveSheet.Cells(Rng.Row, StatusColumn).Value to make sure I was getting the right value and it shows the "Urgent" that is in the cell. Any idea what's up?
Private Sub Worksheet_Change(ByVal Target As Range)
'When the status in Column C is changed, this will make sure the color changes
Dim workRng As Range
Dim Rng As Range
Dim StatusColumn As Integer
Dim CurrentStatus As Variant
StatusColumn = 3
Set workRng = Intersect(Application.ActiveSheet.Range("A:M"), Target)
If Not workRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In workRng
Set CurrentStatus = ActiveSheet.Cells(Rng.Row, StatusColumn).Value
Select Case CurrentStatus
Case "Urgent"
Cells(Rng.Row, workRng).Interior.Color = 8420607
Case "Important"
Cells(Rng.Row, workRng).Interior.Color = 65535
End Select
Next
Application.EnableEvents = True
End If
End Sub
Set CurrentStatus = ActiveSheet.Cells(Rng.Row, StatusColumn).Value
I've done a message box on the ActiveSheet.Cells(Rng.Row, StatusColumn).Value to make sure I was getting the right value and it shows the "Urgent" that is in the cell. Any idea what's up?
Private Sub Worksheet_Change(ByVal Target As Range)
'When the status in Column C is changed, this will make sure the color changes
Dim workRng As Range
Dim Rng As Range
Dim StatusColumn As Integer
Dim CurrentStatus As Variant
StatusColumn = 3
Set workRng = Intersect(Application.ActiveSheet.Range("A:M"), Target)
If Not workRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In workRng
Set CurrentStatus = ActiveSheet.Cells(Rng.Row, StatusColumn).Value
Select Case CurrentStatus
Case "Urgent"
Cells(Rng.Row, workRng).Interior.Color = 8420607
Case "Important"
Cells(Rng.Row, workRng).Interior.Color = 65535
End Select
Next
Application.EnableEvents = True
End If
End Sub