View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Solon Solon is offline
external usenet poster
 
Posts: 11
Default Excel 2003 - Macro for Deleting Rows

Don,
Nice bit, I think I can even somewhat comprehend it. It seemed to work fine
for "Delete Me" and "Testing", but I find that when I type in our 'what'
value which is "25 - Johnson Parts" (Not the quotes) it doesn't work. If I
just put in "25 - " it works fine, but as soon as I throw in a letter, it
doesn't function. I even tried formatting the data in the column as text.

Any ideas what might cause that?

Solon
"Don Guillett" wrote in message
...
Sub findanddeletebottomup()
what = "DELETE ME"
For i = Cells(Rows.Count, "d").End(xlUp).Row To 2 Step -1
If UCase(Cells(i, "d")) = what Then Rows(i).Delete
Next i

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Solon" wrote in message
...
I can do that.. should have thought of it on my own.


Sub Macro1()
'
SearchTerm = "Delete me"
iRowEnd = 3000
iRowStart = 2
'
' Delete unneeded rows
For irows = iRowEnd To iRowStart Step -1
If ActiveSheet.Range("D" & irows) = SearchTerm Then
ActiveSheet.Rows(irows).Delete
End If
Next
End Sub

One of the 'fun' parts of this is that I've never even SEEN the use of
("D" & irows) to establish a range. I don't know which version he's
working with, but my macro experience is largely with Sendkeys and
recording some actions then reviewing the generated code along with some
information sources.....

Anyway, if I can find a way to go to the last used row and start there,
that'd be great. If not, I can manually find that value and enter it into
the macro if needed.
Heck, I may be able to turn the macro on and have it prompt for me to
enter that value..... hmmmm

Solon

"Don Guillett" wrote in message
...
You should always post YOUR macro for comment and suggestion.s

lr=cells(rows.count,activecell.column).end(xldown) .row

However, you need not and should not select it. Post your macro

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Solon" wrote in message
...
Greetings,
Still using Excel 2003. Now that I have a macro that will delete rows,
AND do it from the bottom up, I've got another question.

The guy who gave me the macro said he'd never considered doing a
"Ctrl+Down" to simply go to the last used row, then do his search from
there, but figured that there HAS to be a way to get Excel to set that
row number as a variable, then have the macro use that number as it's
starting point.

But neither of us can figure out how to get the macro to 'get cell row
number' or whatever could then be used as the starting point.

We can tell the macro to

Selection.End(xlDown).Select

But then how do we tell it to say "Oh, I've gone down this many rows"
and set that as the 'rowEnd' variable.

Any ideas?

Solon