#1   Report Post  
Aloysicus
 
Posts: n/a
Default deleting cell with 0

How do I set a macro to delete all 0's in a selected range or is there a
function to do this?

Thanks in advance for your replies.

Aloysicus


  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Assuming the range is column A, this will do it

Dim cLastRow As Long
Dim i As Long

cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = cLastRow To 1 Step -1
If Cells(i, "A").Value = 0 Then
Cells(i, "A").EntireRow.Delete
End If
Next i


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Aloysicus" wrote in message
...
How do I set a macro to delete all 0's in a selected range or is there a
function to do this?

Thanks in advance for your replies.

Aloysicus




  #3   Report Post  
Jason Morin
 
Posts: n/a
Default

Select your range and run this macro:

Sub DeleteZero()
Dim NumRng As Range
Dim cell As Range
On Error GoTo ErrorMsg
Set NumRng = ActiveSheet.Cells _
.SpecialCells(xlCellTypeConstants, 1)
For Each cell In Intersect(Selection, NumRng)
If cell.Value = 0 Then cell.ClearContents
Next
Exit Sub
ErrorMsg:
MsgBox "No cells found!"
End Sub

---
To run, press ALT+F11, go to Insert Module, and paste
in the code above. Press ALT+Q to close. Go to Tools
Macro Macros.

HTH
Jason
Atlanta, GA

-----Original Message-----
How do I set a macro to delete all 0's in a selected

range or is there a
function to do this?

Thanks in advance for your replies.

Aloysicus


.

  #4   Report Post  
Aloysicus
 
Posts: n/a
Default

Thanks guys....both methods works!!!!!!
wrote in message
...
Select your range and run this macro:

Sub DeleteZero()
Dim NumRng As Range
Dim cell As Range
On Error GoTo ErrorMsg
Set NumRng = ActiveSheet.Cells _
.SpecialCells(xlCellTypeConstants, 1)
For Each cell In Intersect(Selection, NumRng)
If cell.Value = 0 Then cell.ClearContents
Next
Exit Sub
ErrorMsg:
MsgBox "No cells found!"
End Sub

---
To run, press ALT+F11, go to Insert Module, and paste
in the code above. Press ALT+Q to close. Go to Tools
Macro Macros.

HTH
Jason
Atlanta, GA

-----Original Message-----
How do I set a macro to delete all 0's in a selected

range or is there a
function to do this?

Thanks in advance for your replies.

Aloysicus


.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make cell data automatically shift up when deleting Orangepegs Excel Discussion (Misc queries) 4 February 26th 05 11:11 PM
How can I make cell data automatically shift up when deleting... Orangepegs Excel Worksheet Functions 1 February 26th 05 04:17 AM
cell is reinserting a formula in even after deleting it. Why Michele Dickinson Excel Discussion (Misc queries) 5 February 8th 05 03:31 PM
VBA 'deleting row if a cell in column A is a zero. Charlie Excel Worksheet Functions 4 December 7th 04 04:50 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"