View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Delete all negative numbers leaving only positive numbers

I really meant this

If Cells(x, 1).Value < 0 Then

Mike

"Mike H" wrote:

right click the sheet tab, view code and paste this in and run it. It looks
for a zero value in column A and deletes the entire row if it finds one.

Sub sonic()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 1).Value = 0 Then
Rows(x).EntireRow.Delete
End If
Next
End Sub

Mike


"Barry Walker" wrote:

Ahh yes,

I did forget to mention that the column of numbers relates to other columns
with corresponding information in them. So i need the formula to delete the
whole row relating to the negative number for all the negative numbers
leaving only positive numbers with their corresponding row information.

Sorry about that, can you still help?

"Gary''s Student" wrote:

If your list is in column A, then in B1 enter:
=IF(A1=0,A1,"")
and copy down. Column B will have the negatives cleared. If you like, you
can copy column B and pastespecial/value back onto column A

--
Gary''s Student - gsnu200754


"Barry Walker" wrote:

I have a column containing positive and negative numbers. I need a formula
that will delete all the negative numbers from the list leaving only the
positive ones.

the list is extremely long so it would help me enormously. I hope someone
can help

Regards

Basil