Looping backward - from last row. Bit confused.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
If the value [date] is <= x then msgbox "yes" & my statement...

Where 'm i doing it wrong...?:)

Thanks.

I know there are cells matching critiria however it does not msgbox ....
Code:
[FONT=Courier New]Option Explicit[/FONT]
[FONT=Courier New]Sub try3()[/FONT]
[FONT=Courier New]Dim x As String[/FONT]
[FONT=Courier New]Dim lr as long, myC As Long 'myC As Range[/FONT]
[FONT=Courier New]x = Date - 90[/FONT]
[FONT=Courier New]lr = Sheet2.Range("A" & Rows.Count).End(xlUp).Row[/FONT]
 
[FONT=Courier New]For myC = lr To 1 - 1[/FONT]
[FONT=Courier New] If Cells(myC, "D").Value <= x Then[/FONT]
[FONT=Courier New] MsgBox "Yes"[/FONT]
[FONT=Courier New] End If[/FONT]
[FONT=Courier New]Next myC[/FONT]
[FONT=Courier New]End Sub[/FONT]

hey i think it should be...
For myC = lr To 1 Step -1
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,224,588
Messages
6,179,743
Members
452,940
Latest member
rootytrip

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