I am using the following VBA code to clear a row when the user clicks on a cell in colum "X". The intent is to clear the single row of data when it is no longer needed. However, this code doesn't just clear the row of data, it actually removes the row and moves all rows below it, up one.
I need a code modification that will only erase the data in the cells of the row ... not delete the entire row from the tab.
Your assistance is appreciated. Thank you.
Sub DeleteRowWithContents()
'========================================================================
' DELETES ALL ROWS FROM X DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D
'========================================================================
Last = Cells(Rows.Count, "X").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "X").Value) = "X" Then
'Cells(i, "A").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW
Cells(i, "X").EntireRow.Delete
End If
Next i
End Sub
Bookmarks