ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to find row and delete it (https://www.excelbanter.com/excel-programming/288333-macro-find-row-delete.html)

Piet Lauwen

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:



Tom Ogilvy

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:






All times are GMT +1. The time now is 07:38 PM.

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