Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
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.





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default 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.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default 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.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
#Ref! after row deletion Rick Excel Discussion (Misc queries) 3 March 19th 10 04:39 PM
Macro deletion Patricia D[_2_] Excel Discussion (Misc queries) 1 July 19th 09 04:58 AM
Deletion Of Cells DDD Excel Worksheet Functions 1 December 10th 08 01:19 AM
How can I activate a macro of auto deletion with respect to date G.Shankar New Users to Excel 1 May 31st 08 01:30 PM
name deletion rk0909 Excel Discussion (Misc queries) 2 January 4th 08 11:03 PM


All times are GMT +1. The time now is 07:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"