RJD1993
10-07-2015, 10:54 AM
Sub DeleteRowWithContents()
Sheets("PS4 Base Sheet").Select
'========================================================================
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D
'========================================================================
Last = Cells(Rows.Count, "C").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "C").Value) = "2016" Then
End If
If (Cells(i, "C").Value) = "TBA" Then
End If
If (Cells(i, "C").Value) = "N/A" Then
End If
If (Cells(i, "C").Value) = "Q4 2015" Then
End If
If (Cells(i, "C").Value) = "Q1 2016" Then
End If
If (Cells(i, "C").Value) = "Q2 2016" Then
'Cells(i, "C").EntireRow.ClearContents 'USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW
Cells(i, "C").EntireRow.Delete
End If
Next i
End Sub
Here's some code I'm working on, I'm new to VBA. I'm trying to delete a row if the values above are in column C. I found some code that I based it on and I'm not getting any errors, but it isn't actually accomplishing anything when I run it. I don't really have any idea what I'm doing.
Sheets("PS4 Base Sheet").Select
'========================================================================
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D
'========================================================================
Last = Cells(Rows.Count, "C").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "C").Value) = "2016" Then
End If
If (Cells(i, "C").Value) = "TBA" Then
End If
If (Cells(i, "C").Value) = "N/A" Then
End If
If (Cells(i, "C").Value) = "Q4 2015" Then
End If
If (Cells(i, "C").Value) = "Q1 2016" Then
End If
If (Cells(i, "C").Value) = "Q2 2016" Then
'Cells(i, "C").EntireRow.ClearContents 'USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW
Cells(i, "C").EntireRow.Delete
End If
Next i
End Sub
Here's some code I'm working on, I'm new to VBA. I'm trying to delete a row if the values above are in column C. I found some code that I based it on and I'm not getting any errors, but it isn't actually accomplishing anything when I run it. I don't really have any idea what I'm doing.