Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
#Ref! after row deletion | Excel Discussion (Misc queries) | |||
Macro deletion | Excel Discussion (Misc queries) | |||
Deletion Of Cells | Excel Worksheet Functions | |||
How can I activate a macro of auto deletion with respect to date | New Users to Excel | |||
name deletion | Excel Discussion (Misc queries) |