Hi,
I am new to VBA, getting a bit of a hang of it.
I found this code via forums etc.
It works to remove rows with dates after a certain value.
I am looking to make it so it does this but with text values / names.
Firstly, can someone help explain parts of the code that I have highlighted in red that I don't exactly understand.
For example 'AS Date', can that be changed to 'AS Text' for example?
Basically I am wanting to do what this code does but if the cell equals completed then cut and past the entire row to the worksheet 2.
Cheers
I am new to VBA, getting a bit of a hang of it.
I found this code via forums etc.
Rich (BB code):
Sub Delete_Data()
Dim i As Long, lastrow As Long, mydate As Date, erow As Long
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).row
Application.ScreenUpdating = False
For i = lastrow To 2 Step -1
mydate = Cells(i, "C")
If mydate > DateValue("april 20, 2019") Then
Cells(i, "c").EntireRow.Cut
erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).row
ActiveSheet.Paste Destination:=Worksheets("Sheet2").Rows(erow)
End If
Next i
Delete_Blank_Rows
End Sub
Sub Delete_Blank_Rows()
Dim row As Long
lastrow = ThisWorkbook.Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).row
row = 2
For row = row To lastrow
If Cells(row, 1) = "" Then
Cells(row, 1).EntireRow.Delete
End If
Next row
End Sub
It works to remove rows with dates after a certain value.
I am looking to make it so it does this but with text values / names.
Firstly, can someone help explain parts of the code that I have highlighted in red that I don't exactly understand.
For example 'AS Date', can that be changed to 'AS Text' for example?
Basically I am wanting to do what this code does but if the cell equals completed then cut and past the entire row to the worksheet 2.
Cheers
Last edited by a moderator: