ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   deletion macro (https://www.excelbanter.com/excel-programming/275479-deletion-macro.html)

Bob[_31_]

deletion macro
 
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.


Tom Ogilvy

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.






Bob[_31_]

deletion macro
 
Thanks guys for your fast response. This will save a ton
of time!

Bob P.

-----Original 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.

.


Ken Wright

deletion macro
 
Slight typo, you need the second set of Quotes on the ("A:A) bit, eg ("A:A").

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL2K & XLXP

----------------------------------------------------------------------------
Attitude - A little thing that makes a BIG difference
----------------------------------------------------------------------------



"steve" wrote in message ...
Bob,

Dim rng As Range, myval as Double
myval = Range("D1").Value
Set rng = Range("A:A).Find(myval)
If Not rng Is Nothing Then
Rows(rng.Row).EntireRow.Delete
Else
MsgBox ("not found")
End If

Try this out...
(original code "stolen" from this ng)
--
sb
"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.






steve

deletion macro
 
Thanks Ken! Got a bit rushed...

--
sb
"Ken Wright" wrote in message
...
Slight typo, you need the second set of Quotes on the ("A:A) bit, eg

("A:A").

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL2K & XLXP

--------------------------------------------------------------------------

--
Attitude - A little thing that makes a BIG difference
--------------------------------------------------------------------------

--



"steve" wrote in message

...
Bob,

Dim rng As Range, myval as Double
myval = Range("D1").Value
Set rng = Range("A:A).Find(myval)
If Not rng Is Nothing Then
Rows(rng.Row).EntireRow.Delete
Else
MsgBox ("not found")
End If

Try this out...
(original code "stolen" from this ng)
--
sb
"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.









All times are GMT +1. The time now is 03:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com