I am trying to get my function to alter the cell color of the cell where the function is being called. I found some good advice on this question, but I'm running into a #VALUE! error with the following code (the rest of the function works as expected with this omitted).
Inside of main function:
Dim checkCounter As Long
checkCounter = 0
When certain if statements are executed, checkCounter = checkCounter + 1
.
Also inside of main function:
If checkCounter <> 0 Then
With Application.Caller
.Parent.Evaluate "Changeit(" & .Address(False, False) & ")"
End With
'Else (would like to get this working as well)
With Application.Caller
.Parent.Evaluate "Clearit(" & .Address(False, False) & ")"
End With'
End If
ChangeIt Sub:
Sub ChangeIt(cl as Range)
cl.Interior.ColorIndex = 22
'cl.Font.ColorIndex = 9 (would like this to function as well)'
End Sub
(Potential) ClearIt Sub:
'Sub ClearIt(cl as Range)
cl.Interior.ColorIndex = 0
cl.Font.ColorIndex = 1
End Sub'
If I edit a precedent cell (for function parameters), the fill color will apply but the #VALUE! error still remains. Any way to fix this?
Side question: Why does/should .Parent.Evaluate "Clearit(" & .Address(False, False) & ")"
work with Clearit when the sub is ClearIt?