Do you want the code to treat a blank cell as a zero or as a blank?
This will not clear the row if either column A or B is blank:
If Range("A" & i).Formula = 0 And Range("B" & i).Formula = 0 Then
This will clear the row if either is column A or B blank:
If Range("A" & i).Value = 0 And Range("B" & i).Value = 0 Then
The entire code:
Option Explicit
Sub ProcessMyData()
'===================================================================
'Declare Variables
'===================================================================
Dim wsName As String
Dim LastRow As Long
Dim i As Long
'===================================================================
'Define Variables
'===================================================================
wsName = ActiveSheet.Name 'Defines the SheetName
LastRow = Worksheets(wsName).Cells(Rows.Count, 1).End(xlUp).Row 'This will find the last used row in column A
'===================================================================
'Do Work
'===================================================================
For i = 1 To LastRow 'this willl loop through all of the cells
If Range("A" & i).Formula = 0 And Range("B" & i).Formula = 0 Then 'this will think a blank cell in Bi is NOT zero, is that acceptable?
Rows(i & ":" & i).ClearContents 'do you want to DELETE the row or just clear it?
End If
Next i 'loops to the next i, which moves down one row
'===================================================================
'End Macro
'===================================================================
End Sub
Here is the file I created while creating this:
ClearRowContents.xlsm
Bookmarks