delete rows

k_babb

Board Regular
Joined
Mar 28, 2011
Messages
71
can someone help with this macro i want to delete the row if column C does not contain a date
this macro seams to delete lots of cells that contain a date

Code:
Sub clearondate()

Range("A1:f6000").Select
Dim i As Long



    'We turn off calculation and screenupdating to speed up the macro.

    With Application

        .Calculation = xlCalculationManual

        .ScreenUpdating = False

      

    'We work backwards because we are deleting rows.

    For i = Selection.Rows.Count To 1 Step -1

       If WorksheetFunction.CountA(Range("c" & i) = 0) Then

            Rows(i).Delete

        End If

    Next i
end with
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
If a cell in Column C does not contain a date, will it be blank? Or could there be other values besides dates in there and, if so, what? Also, are the values in Column C contants or formulas?
 
Upvote 0
Try this
Code:
If Not  Isdate(Cells(i,"C")) Then Rows(i).EntireRow.Delete

lenze
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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