Conditional Format VBA question

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
710
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Hey gang,
I have trying to figure out the "Conditional Format" in VBA, as I have 5 conditions that I need to work with. I have found several post regarding the question, but I'm not sure I understand.
What I am trying to do is simple (I think), maybe one of you could lend a hand on the first one, and I can do the rest, anyway.....

(This is for calculation vacation time based on years of service)

If cell T8 is 0 then cell P7 = the value of cell S7
If cell T8 is between 1 and 4 then cell P7 = 80
If cell T8 is between 5 and 9 then cell P7 = 120
If cell T8 is between 10 and 19 then cell P7 = 160
If cell T8 is = to (or) greater > 20 then cell P7 = 200

Thanks for any assistance,
Pujo
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Pujo,

Here's a quick "translation" of your code:

Code:
    Dim v As Integer
    v = CInt(Range("T8").Text)
    If v = 0 Then
        Range("P7") = Range("S7")
     ElseIf v >= 1 And v <= 4 Then
        Range("P7") = 80
     ElseIf v >= 5 And v <= 9 Then
        Range("P7") = 120
    ElseIf v >= 10 And v <= 19 Then
        Range("P7") = 160
    ElseIf v >= 20 Then
        Range("P7") = 200
    End If
 
Upvote 0
That seems to be exactly what I needed.
Thanks & Have a great day!!!!
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,703
Members
452,938
Latest member
babeneker

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