function breaking, not sure why

emorris1000

Registered User.
Local time
Yesterday, 16:45
Joined
Feb 22, 2011
Messages
125
I have a function that isn't working properly and I can't figure out why

here is where it's called:

Code:
...
Dim xlMDSheetRaw As Excel.Worksheet
Dim Datastop As Long
 
...
 
Datastop = FindOne(2, xlMDSheetRaw)
 
...
 

Function FindOne(Start As Long, ByRef xlSheet As Excel.Worksheet) As Long

MsgBox "working2"
With xlSheet
    FindOne = .Range(.Cells(Start, 2), .Cells(5000, 2)).Find(What:=1, after:=.Cells(Start, 2), LookIn:=xlValues, lookat:=xlWhole).Row
End With

MsgBox "working3"

End Function


"Working2" comes up ok, but "working3" doesn't. It doesn't throw an error, the program just stops running at this point. This usually is caused by an unclear reference to an excel value/object (saying Cells as opposed to xlsheet.cells, but I think I've got that covered here correctly.

Any ideas as to why?
 
ok, found one candidate for the error. I changed:

LookIn:=xlValues, lookat:=xlWhole

to

LookIn:= Excel.xlValues, lookat:= Excel.xlWhole

but that still didn't fix it
 

Users who are viewing this thread

Back
Top Bottom