JeffGrant
Well-known Member
- Joined
- Apr 7, 2021
- Messages
- 516
- Office Version
- 365
- Platform
- Windows
Hi All,
I have a userform that when initialised I would like the forecolor changed if the value in a cell is not empty.
This would give a quick visual to indictae what cells are empty.
My code is this:
However, in cells T3, U3, V3 & W3, the are formulas such as:
=IF(OR($P$2="No",T2=""),"",XLOOKUP(T2,$H$2:$H$25,$D$2:$D$25)), so T3 to W3, is not actually empty.
Can somebody please give me some guidance how to change the forecolor of the userform when the above formula equates to "".
Thanks
I have a userform that when initialised I would like the forecolor changed if the value in a cell is not empty.
This would give a quick visual to indictae what cells are empty.
My code is this:
VBA Code:
Private Sub UserForm2_Initialize()
'If cellnot empty change label colour
With Sheet1
If Range("T3").Value <> "" Then UserForm2.Opt1.ForeColor = RGB(0, 0, 255)
If Range("U3").Value <> "" Then UserForm2.Opt2.ForeColor = RGB(0, 0, 255)
If Range("V3").Value <> "" Then UserForm2.Opt3.ForeColor = RGB(0, 0, 255)
If Range("W3").Value <> "" Then UserForm2.Opt4.ForeColor = RGB(0, 0, 255)
End With
UserForm2.Show
End Sub
However, in cells T3, U3, V3 & W3, the are formulas such as:
=IF(OR($P$2="No",T2=""),"",XLOOKUP(T2,$H$2:$H$25,$D$2:$D$25)), so T3 to W3, is not actually empty.
Can somebody please give me some guidance how to change the forecolor of the userform when the above formula equates to "".
Thanks