if statement for Percent

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
I have this if/then statement that doesn't run correctly. lbSL is a label on a userform that displays 5.5% and it should execute the first part of the if/then statement. However, it executes the second part of the if/then statement. My guess the code does not recognize the lbSl.Caption as a value. Can someone assist thank you.


lbSL.Caption = 5.5%

Code:
    If lbSL.caption < "15%" Then
        lbRatio = "Ok"
        lbRatio.ForeColor = vbBlue
    Else
        lbRatio = "Caution"
        lbRatio.ForeColor = vbRed
    End If
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try using evaluate and use 0.15 for the percentage. I believe that will work:

Code:
If Evaluate(lbSL.caption) < 0.15 Then
 
Upvote 0
Works great. Can you explain why the code does not recognize the value? Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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