VBA: change label forecolor (Integer)

Xlacs

Board Regular
Joined
Mar 31, 2021
Messages
105
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I'm wondering if I'm doing this correctly because my label caption forecolor remains "red" given my code below.
Hoping some could enlighten me with the below code. Thank you!!

VBA Code:
If Val(Me.lbl1.caption) < 85 Then
Me.lbl1.forecolor = RGB(255,0,0,)
Else
Me.lbl1.forecolor = RGB(0,0,0)

End If

I also tried

VBA Code:
If Val(Me.lbl1) < 85 Then
    Me.lbl1.forecolor = RGB(255,0,0,)
    Else
    Me.lbl1.forecolor = RGB(0,0,0)
    
    End If

However, the result is regardless the value, the forecolor remains red.
 
I moved the code I posted into an Excel userform and it still works. Unless you can make a file available for download I don't see what else I can suggest that I haven't already.
 
Upvote 0
Solution

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hmm
I moved the code I posted into an Excel userform and it still works. Unless you can make a file available for download I don't see what else I can suggest that I haven't already.

Hmm. I guess the only option is to switch to textbox. anyway, Thanks a Lot Micron!!
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top