Hi all
I want to delete contents of a sheet based upon some criteria. I am very basic in VBA. I created Select and ClearContent by recording macro. But, I am not sure how to add criteria.
Here is my code.
Now, I want to add the criteria as described on the comment.
The criteria cell is one column left and two column up of the first cell in range.
Do I have to write the if statement for every range I try to delete or it can be written once and works for every range?
I want to delete contents of a sheet based upon some criteria. I am very basic in VBA. I created Select and ClearContent by recording macro. But, I am not sure how to add criteria.
Here is my code.
Code:
Sub DeleteData()
' If B3 is not empty and not equal to ""
Range("C5:D6").Select
Selection.ClearContents
' If H3 is not empty and not equal to ""
Range("I5:J6").Select
Selection.ClearContents
End Sub
Now, I want to add the criteria as described on the comment.
The criteria cell is one column left and two column up of the first cell in range.
Do I have to write the if statement for every range I try to delete or it can be written once and works for every range?