Clear Cell Contents

  • Thread starter Thread starter workerboy
  • Start date Start date
W

workerboy

Hi,

I was wondering if it was possible to clear the contents of a range of
cells in one row, if one of the cells in that range equals a certain
value.

For example if cell C2 = "THING", clear the contents of cells C2:G2.
I need this to go through a range such as from C2:C1000 and perform
that function each time C2,D2,E2,etc equals "THING"

Thanks to anyone who can help me out on this one!
 
for each cell in Range("C2:C1000")
if lcase(cell.Value) = "thing" then
cell.Resize(1,5).ClearContents
end if
Next

another faster way

set rng = Columns(3).find("THING")
if not rng is nothing then
do
rng.Resize(1,5).clearContents
set rng = Columns(3).FindNext(rng)
Loop while not rng is nothing
End if
 
Thanks a lot for all your help, it worked like a charm!

I have to admit i probably didnt understand much of it. My VBA
knowledge is very basic at the moment...
 
Back
Top