Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default If Cells.Find returns run-time error '91': Object variableor With block variable not set

I have the following marco that I have used with success to search through donwloaded data and take an action if "No Schedule" is found in the data. It has stopped functioning now and i get....Run-time error '91': Object variable or With block variable not set. I do not understand why it worked for months and now has stopped? The macro is below.

Sub FindNoSked()
If Cells.Find(What:="No Schedule", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False) = False Then
Exit Sub
End If
'copies No Schedule row if presentand appends
Cells.Find(What:="No Schedule", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
ActiveCell.Range("A1:N1").Select
Selection.Copy
Application.Goto Reference:="R1500C1"
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Select
Application.CutCopyMode = False
End Sub

Thanks for any help!

Tonso
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default If Cells.Find returns run-time error '91': Object variable or With block variable not set

Hi Tonso,

Am Tue, 13 Nov 2012 05:05:07 -0800 (PST) schrieb Tonso:

I have the following marco that I have used with success to search through donwloaded data and take an action if "No Schedule" is found in the data. It has stopped functioning now and i get....Run-time error '91': Object variable or With block variable not set. I do not understand why it worked for months and now has stopped? The macro is below.


the error comes if "No Schedule" is not found.
Try:

Sub FindNoSked()
Dim SRow As Long
Dim LRow As Long

On Error Resume Next
If Cells.Find(What:="No Schedule", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False) = False Then Exit Sub

'copies No Schedule row if presentand appends
SRow = Cells.Find(What:="No Schedule", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
LRow = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(SRow, "A"), Cells(SRow, "N")).Copy _
Destination:=Cells(LRow + 1, "A")

Application.CutCopyMode = False
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
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
Run-time error 91: Object Variable or With block variable not set Ayo Excel Programming 1 August 17th 09 11:29 PM
Run-Time error '91': Object variable of With block variable not set jammin1911 Excel Programming 3 June 6th 06 06:36 PM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
"Run-time error 91: Object variable or With block not set" Snedker Excel Programming 0 January 10th 04 09:37 AM


All times are GMT +1. The time now is 02:43 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"