[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Delete Cell Contents IF

joecrabtree

12/18/2006 2:02:00 PM

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

3 Answers

Don Guillett

12/18/2006 2:10:00 PM

0

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

--
Don Guillett
SalesAid Software
dguillett1@austin.rr.com
"joecrabtree" <thejoecrabtree@gmail.com> wrote in message
news:1166450501.997603.238630@48g2000cwx.googlegroups.com...
> 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
>


james.billy

12/18/2006 2:13:00 PM

0

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

joecrabtree wrote:
> 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

Mike Fogleman

12/18/2006 2:21:00 PM

0

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
"joecrabtree" <thejoecrabtree@gmail.com> wrote in message
news:1166450501.997603.238630@48g2000cwx.googlegroups.com...
> 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
>