Diane has attended:
Excel VBA Advanced course
Custom functions
Hi
I've created a quick custom function where I want the background colour of a cell to change if another cell has the word 'yes' entered.
Is there anything obviously wrong with the below?
Function ThreeD(B As String)
If B = "Yes" Then
ThreeD.Interior.Color = RGB(127, 127, 127)
Else
ThreeD = 0
End If
End Function
Thanks! Diane
RE: custom functions
Hi Diane
Thanks for the question
It is not possible to use a function to achieve what you are attempting
I have created the following sub procedurenwhich you can adapt to solve your problem
Sub ThreeD()
Dim B As String
B = Cells(1, 1).Value
If B = "Yes" Then
Cells(1, 1).Interior.Color = RGB(127, 127, 127)
Else
Cells(1, 1).Interior.Color = RGB(0, 0, 0)
End If
End Sub
Hope this helps
Regards
Stephen