Looping with an if statment

seasmith

New Member
Joined
Jul 6, 2011
Messages
44
I have dates in column L that have the conditional formatting of:

Cell Value <= Today()-365*(3*$N7:$N$368)-182

I need to loop thru every row in column L and see if the conditional formatting is true or not. I know C pretty well but am still farely new to VBA and arent quite sure how to do it. Any help would be great!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
There's no easy way to test if conditional formatting is true/false in a particular cell.

The trick is to test for the condition itself instead..


Hope that's helpfull.
 
Upvote 0
that is what I was planning on doing but I'm not quite sure how I would type those conditions into VBA code
 
Upvote 0
Maybe, if the range is constant, something like

Code:
    Dim i As Long
    
    For i = 7 To 368
        If Range("L" & i) <= (Date - 365 * (3 * Range("N" & i)) - 182) Then
            'Your code here
        End If
    Next i

M.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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