Macro to find and delete rows!

H

Heather O'Malley

I am trying to find and delete specific rows in a spreadsheet, however the reference I=
=E2=80=99m looking for e.g. 800411 is not always going to be in the spreadsheet, so my=
macro is not working on all occasions =E2=80=93 any ideas how I can overcome this.

Macro so far: =


Sheets("top10month").SelectCells.Find(What:=3D"800411", After:=3DActiveC=
ell, LookIn:=3DxlFormulas, LookAt _
:=3DxlPart, SearchOrder:=3DxlByRows, SearchDirection:=3DxlNext, MatchCase:=
=3D _
False, SearchFormat:=3DFalse).Activate
ActiveCell.Rows("1:1").EntireRow.Select
Application.CutCopyMode =3D False
Selection.Delete Shift:=3DxlUp
ActiveCell.Select
=

Any help is appreciated this is a great forum for beginners like me! Thanks
 
D

Dave Peterson

Dim FoundCell as Range
with Worksheets("Top10Month")
set foundcell = .cells.find(What:="800411", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
if foundcell is nothing then
'not found
else
foundcell.entirerow.delete
end if
end with
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Problem with Macro 7
Macro to find and paste rows 5
Loop Macro 2
macro to delete multiple rows 5
Inserting rows and adding to total worksheet 3
conso macro 0
VBA, find and replace 2
Find funtion in macro 5

Top