Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to find row and delete it

Hi group,

I am working on this macro now for some days now but with no succes....

From Worksheet3 I ask input for an "Item" (f.i. serialnumber) with an input
box.
The "item" has to be found in the first collumn of a database in
Worksheet2.
When the "Item" is found the complete row where it is foud should be
deleted.

What approach should I take?

Thanks in Adavance,

Piet Lauwen

e-Mail:


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to find row and delete it

Dim rng as Range
Dim sItem as String
Dim res as Variant
do until len(Trim(sItem)) 0
sItem = InputBox("Input Serial Number:")
Loop
With Worksheets("Sheet2")
set rng = .Range( _
.Cells(2,1),.Cells(rows.count,1).end(xlup))
End With
res = Application.Match(sItem, rng, 0)
if not iserror(res) then
rng(res).EntireRow.Delete
End if


if the serial number and values in Column A of sheet2 will be numeric
change

res = Application.Match(clng(sItem), rng, 0 )

--
Regards,
Tom Ogilvy


Piet Lauwen wrote in message
...
Hi group,

I am working on this macro now for some days now but with no succes....

From Worksheet3 I ask input for an "Item" (f.i. serialnumber) with an

input
box.
The "item" has to be found in the first collumn of a database in
Worksheet2.
When the "Item" is found the complete row where it is foud should be
deleted.

What approach should I take?

Thanks in Adavance,

Piet Lauwen

e-Mail:




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
find and delete rows macro clayton ledford Excel Discussion (Misc queries) 4 January 20th 09 03:34 PM
find last record in macro and delete all after Sherife Excel Discussion (Misc queries) 3 September 18th 06 03:51 AM
Macro to find and delete rows! Heather O'Malley Excel Discussion (Misc queries) 2 April 12th 06 01:53 PM
Can't find macro in an Excel file to delete it Ron Excel Discussion (Misc queries) 3 July 1st 05 01:07 PM
Macro to find and delete all FALSE statements Woody13 Excel Discussion (Misc queries) 3 December 8th 04 11:16 PM


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

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

About Us

"It's about Microsoft Excel"