#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Error 91

I'm using this code to search for a certain 5 digit number eg 88860

Dim cl As Long
Sheets("Milestone").Select
Range("C2").Select
cl = ActiveCell 'Set cl as number 88860
Sheets("Master").Select
Range("A4").Select
Cells.find(What:=cl, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate

and an error comes up at this point saying something like I have not set the
variable. I've used this code loads iof times before with no problem, so I
don't know whats up. Any help?


--
Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Error 91

Hi
Try
cl = Activecell.Value

regards
Paul

as cl is a range object.
DaveyJones wrote:
I'm using this code to search for a certain 5 digit number eg 88860

Dim cl As Long
Sheets("Milestone").Select
Range("C2").Select
cl = ActiveCell 'Set cl as number 88860
Sheets("Master").Select
Range("A4").Select
Cells.find(What:=cl, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate

and an error comes up at this point saying something like I have not set the
variable. I've used this code loads iof times before with no problem, so I
don't know whats up. Any help?


--
Dave


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Error 91

I gave it a go but the error still comes up. The rest of the code works great
if I just set a cell as the activecell then run the sub, but as soon as I try
to set the activecell with the find function, it gives me the error.
--
Dave


" wrote:

Hi
Try
cl = Activecell.Value

regards
Paul

as cl is a range object.
DaveyJones wrote:
I'm using this code to search for a certain 5 digit number eg 88860

Dim cl As Long
Sheets("Milestone").Select
Range("C2").Select
cl = ActiveCell 'Set cl as number 88860
Sheets("Master").Select
Range("A4").Select
Cells.find(What:=cl, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate

and an error comes up at this point saying something like I have not set the
variable. I've used this code loads iof times before with no problem, so I
don't know whats up. Any help?


--
Dave



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Error 91

The number was not found, so there is no cell to activate.
This works...

Sub AreYouThere()
Dim cl As Double
Dim rngFound As Excel.Range

cl = Sheets("Milestone").Range("C2").Value 'Set cl as number 88860
Set rngFound = Sheets("Master").Cells.Find(What:=cl, After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not rngFound Is Nothing Then
Application.Goto rngFound, True
MsgBox rngFound.Address(external:=True)
Else
MsgBox cl & " not found. "
End If
End Sub
------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"DaveyJones"

wrote in message
I'm using this code to search for a certain 5 digit number eg 88860

Dim cl As Long
Sheets("Milestone").Select
Range("C2").Select
cl = ActiveCell 'Set cl as number 88860
Sheets("Master").Select
Range("A4").Select
Cells.find(What:=cl, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= False).Activate

and an error comes up at this point saying something like I have not set the
variable. I've used this code loads iof times before with no problem, so I
don't know whats up. Any help?
--
Dave
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Error 91

Oh how I love the excel error messages. Thanks alot Jim. If i'd have known
that I could have sorted it myself. I missed off a possible value of cl so it
was not finding it, thanks alot.
--
Dave


"Jim Cone" wrote:

The number was not found, so there is no cell to activate.
This works...

Sub AreYouThere()
Dim cl As Double
Dim rngFound As Excel.Range

cl = Sheets("Milestone").Range("C2").Value 'Set cl as number 88860
Set rngFound = Sheets("Master").Cells.Find(What:=cl, After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not rngFound Is Nothing Then
Application.Goto rngFound, True
MsgBox rngFound.Address(external:=True)
Else
MsgBox cl & " not found. "
End If
End Sub
------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"DaveyJones"

wrote in message
I'm using this code to search for a certain 5 digit number eg 88860

Dim cl As Long
Sheets("Milestone").Select
Range("C2").Select
cl = ActiveCell 'Set cl as number 88860
Sheets("Master").Select
Range("A4").Select
Cells.find(What:=cl, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= False).Activate

and an error comes up at this point saying something like I have not set the
variable. I've used this code loads iof times before with no problem, so I
don't know whats up. Any help?
--
Dave

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
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Form Err.Raise error not trapped by entry procedure error handler [email protected] Excel Programming 1 February 8th 06 10:19 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


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