VBA - On Error Resume Next

george hart

Board Regular
Joined
Dec 4, 2008
Messages
241
The code below works fine if I have an actual date in column AJ. However, should column AJ contain anything other than a date - for example text it falls over.

In short i need to amend the code so that If any cells in column column AJ <> date do nothing, else carry on.

The "On Error Resume Next" doesn't appear to work??

Code:
On Error Resume Next
For x = 5 To Cells(Rows.Count, "A").End(xlUp).Row
Dim a As Date, b As Date
a = Worksheets("Gateline Database").Range("AJ" & x)
b = Date
If Worksheets("Gateline Database").Range("AN" & x) = "" _
And Worksheets("Gateline Database").Range("AJ" & x) <> "" _
And a - b <= 28 Then
 
Do something....I have left this code out...

Any ideas most appreciated and thanks in advance...
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try this and let me know how it goes
Code:
    Dim a As Date, b As Date, x As Long
    b = Date
    With Worksheets("Gateline Database")
        For x = 5 To .Cells(.Rows.Count, "A").End(xlUp).Row
            If IsDate(.Range("AJ" & x)) Then
                a = .Range("AJ" & x)
                If .Range("AN" & x) = "" And a - b <= 28 Then
                    'Do stuff here
                End If
            End If
        Next x
    End With
 
Upvote 0

Forum statistics

Threads
1,224,271
Messages
6,177,609
Members
452,785
Latest member
3110vba

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