jsbxd9
- 5
- 0
Hello all. I am trying to get my code to color cells if a referenced cell is populated. That part works but when I tried to populate another cell a different color I encountered a problem. You can see where the mistake comes in on the code. It is when I try to populate a variable 'strMyVar' with an offset property. I have underlined where I am having the problem. Any suggestions?
Sub colorcells()
Dim x, n, y, i As Double
Dim strMyVal As String
For n = 1 To 3000
Cells(n, 1).Activate
If Cells(n, 1) <> ("") Then
For x = 1 To 7
If x < 7 Then
Cells(n, x).Activate
ActiveCell.Interior.Color = RGB(252, 213, 180)
End If
If x >= 7 Then
Cells(n, x).Activate
strMyVal = ActiveCell.Offset(-3, 0).Value
If strMyVal <> ("") Then
ActiveCell.Interior.Color = RGB(255, 255, 153)
End If
End If
Next x
x = 1
End If
Next n
End Sub
Sub colorcells()
Dim x, n, y, i As Double
Dim strMyVal As String
For n = 1 To 3000
Cells(n, 1).Activate
If Cells(n, 1) <> ("") Then
For x = 1 To 7
If x < 7 Then
Cells(n, x).Activate
ActiveCell.Interior.Color = RGB(252, 213, 180)
End If
If x >= 7 Then
Cells(n, x).Activate
strMyVal = ActiveCell.Offset(-3, 0).Value
If strMyVal <> ("") Then
ActiveCell.Interior.Color = RGB(255, 255, 153)
End If
End If
Next x
x = 1
End If
Next n
End Sub