Hi, Give me a sample file I will solve this for you.
Regards, Deepak On Tue, Jun 8, 2010 at 8:35 PM, molinari <dh0...@gmail.com> wrote: > I have a list of reports to be printed out Monday - Friday, where each > worksheet is Monday, Tuesday, Wednesday, Thursday, or Friday. I made > another worksheet to list reports that we no longer need (by their > report number). I want the macro to go through the worksheet and > delete the rows that correspond to these reports, but I'm getting > stuck at the find step: it keeps giving me this error about "Object or > variable with block variable not set". > > How do I fix this? (then afterwards, how do I tell it to delete the > rows where it found something, but not delete the row its on if it > finds nothing?) > > Sub Macro5() > ' > ' Macro5 Macro > ' Macro recorded 6/8/2010 by David J. Heinrich > > Dim y As Byte > Sheets("Reports Not Needed").Select > y = xlLastRow ' y = numbers of rows > > Dim ReportsNotNeeded() As Variant > ReportsNotNeeded = Range(Cells(2, 2), Cells(y, 2)).Value > > Dim ws As Worksheet > Dim x As Byte > > For Each ws In Worksheets > Sheets(ws.Name).Select > For x = 1 To y - 1 > > Range("B3:B1391").Select > Selection.Find( _ > What:=ReportsNotNeeded(x, 1), _ > After:=Range("B3"), _ > LookIn:=xlValues, _ > LookAt:=xlWhole, _ > SearchOrder:=xlByColumns, _ > SearchDirection:=xlNext, _ > MatchCase:=False, _ > SearchFormat:=False).Activate > > Next x > > Next ws > > End Sub > > -- > > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > HELP US GROW !! > > We reach over 7000 subscribers worldwide and receive many nice notes about > the learning and support from the group.Let friends and co-workers know they > can subscribe to group at > http://groups.google.com/group/excel-macros/subscribe > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 7000 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe