View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
BurtArkin BurtArkin is offline
external usenet poster
 
Posts: 7
Default deleting negative numbers

The code worked perfectly! Thank you. The other issue is this--I want the
spreadsheet to import data, which is what "macro1" does. Then I run
"macro2", and then the one you supplied. What I would like is to combine all
the macros into one, or try to "call" the second and then the third. When I
place your addition into "macro2" nothing happens. Am I missing a step, or
is there a way to stop/start? Appreciate your help. By the way, if all this
could be done while the user remains in Access, and just imports the results
of the spreadsheet, that would be really perfect! Thanks
--
Burt


"Rick Rothstein (MVP - VB)" wrote:

I think this will remove the rows you want to remove (test on a copy of your
data first to be sure)...

Sub RemoveNegativeRows()
Dim X As Long
Dim LastCell As Long
With Worksheets("Sheet2")
LastCell = .Cells(Rows.Count, "I").End(xlUp).Row
For X = LastCell To 1 Step -1
If .Cells(X, "I").Value = 0 Then Exit For
.Cells(X, "I").EntireRow.Delete
Next
End With
End Sub

I'm not exactly sure what you mean by the new question you have added about
the second macro. Perhaps if you posted some code for this second macro, and
provide an expanded description of what it is supposed to do and what it
actually is doing, then maybe someone here can suggest something to you.

Rick


"BurtArkin" wrote in message
...
The former is correct, and the first negative number appears in column I
(eye). Also, when I try to call a second macro, the directions somehow
"lose" their way, and fill in data in columns to the right of the regular
data. How can I regulate that? The reason is I want the macros to run in
sequence, transparent to the user. Thanks again.
--
Burt


"Rick Rothstein (MVP - VB)" wrote:

Do you want to delete the row if any cell in the row is negative or only
if
all the cells in the row are negative? If the former, is there one
particular column that goes negative before any of the others do (if so,
that will make for more efficient code)?

Rick

"BurtArkin" wrote in message
...
I have an amortization table where the numbers eventually turn negatve.
How
can I find the negative numbers and delete all rows where a negative
number
appears? Thanks for your anticipated response.
--
Burt