Thread: deletion macro
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default deletion macro

if there are two adjacent rows both having the value in D1, this will only
delete one of them. (In xl97 or later)

Looping in reverse, as shown by some of the other posters will avoid this.

--
Regards,
Tom Ogilvy

"Jean-Paul Viel" wrote in message
.. .
Hi,



Use a macro like that one:



Sub DelRow()

Dim rg As Range

Range("a:a").Select

For Each rg In Selection

If rg.Value = Range("d1").Value Then

rg.Rows.Delete xlUp

End If

Next

Range("d1").Select

End Sub




--
JP

http://www.solutionsvba.com


"Bob" wrote in message
...
Hello All,

I need help with a simple macro to delete an entry and
then delete the row that contained that entry.

Column A contains numbers. I would like to enter a number
in say cell D1. If that number is in column A then delete
that number and the row.

Thanks for any help!
Bob P.