Hi everyone,
I had some help with a recent problem in clearing offset cells. The code suggested worked very well until I required a different column arrangement. Hoping someone could shed some light on a fix.
Here is the problem (excel file included):
I want to remove values from column D & E, under the condition that columns A & B have values in them. The current code removes required values from column D & E.
I have tried including an if statement to say, "if the value in column A & B are <>"", then clear offset cells in columns C&D". This approach does not seem to work. When the code is run, offset cells are removed all the way down to the end of the month, which I am don't want.
Hope someone can help
Here is my code:
Sub Clearcells()
Dim rng As Range
Dim Ar As Areas
Set Ar = Range("B5", Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
For Each rng In Ar
rng.Offset(, 2).Resize(, 1).ClearContents
Next rng
Dim rng2 As Range
Dim Ar2 As Areas
Set Ar2 = Range("C5", Range("C" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
For Each rng2 In Ar2
rng2.Offset(, 2).Resize(, 1).ClearContents
Next rng2
End Sub
Bookmarks