ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Cell Contents IF (https://www.excelbanter.com/excel-programming/379605-delete-cell-contents-if.html)

joecrabtree

Delete Cell Contents IF
 
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


Don Guillett

Delete Cell Contents IF
 
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

"joecrabtree" wrote in message
ups.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




[email protected]

Delete Cell Contents IF
 
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

Delete Cell Contents IF
 
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" wrote in message
ups.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





All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com