Delete Cell Contents IF

  • Thread starter Thread starter joecrabtree
  • Start date Start date
J

joecrabtree

To all,

I have a worksheet full of numbers ( DATA1 ), I want a macro to be able
to go throught this worksheet, and delete all values that are greater
than or equal to 2000. Any ideas?

Thanks in advance

Joseph Crabtree
 
You didn't specify but try this idea
for each c in range("a1:c100")
if c>=2000 then c.clear
next c
 
Hi Joe,

dim xCell as range, xRng as range
xRng = Range("A1:Z2000") '<- Replace with your range
for each xCell in xRng
if xCell >= 2000 then
xcell.clearcontents
end if
next xcell

This should hopefully get you started, any problems then post back.

James
 
I assume you don't really want them deleted, which would shift the cells
around, but just cleared.

Sub test()
Dim rng As Range, c As Range
Set rng = ActiveSheet.UsedRange
For Each c In rng
If c.Value >= 2000 Then c.Clear
Next
End Sub

Mike F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top