VBA - Object Variable or With Block not set

R

Redwings

To all -

I get the error in the subject line when I try to reset the variabl
"sAddress" at the end of the loop. I think it has something to do wit
the loop but I am not sure being this is my first Excel VBA Program.
Of Course this is only a portion of the entire code.

The data I search through is set up thusly

A Name

Various Dates

"Agent"

The data repeats itself with there being multiple instances of the sam
name. Between each date is a set of data. I am attempting to searc
through the sheet from top to bottom for each instance of the name an
get certain data from each instance. The data is always in this orde
and the string "Agent" is at the end of the data for each Name. I ge
the address of the current instance of Name and use it as the rang
between it and the end of the sheet "sSklstEnd" to search for the th
string "Agent". I use the address of agent to form a range between th
Name address and the "Agent" address to search for a given date. I
the date is not present, I extract other needed data and then I attemp
to find the next instance of the Name to go through the previou
process. I am attempting to terminate the loop when the given rang
does not yeild another instance of the Name.

If more info is needed pls let me know. Thanks.


Case Is > 1
sAddress = Range("A1:"
sSklstEnd).Find(sNameOnRpt).Address
iLoopCnt = 1
Do
sAgentAddress = Range(sAddress & ":"
sSklstEnd).Find("Agent").Address
If Not Range(sAddress & ":"
sAgentAddress).Find(sDate) Is Nothing Then
Call sCall_Data(iRowCnt1, sNameOnRpt, sSklstEnd
sDNEnd, False, iFreq, iLoopCnt)
End If
Call sCall_Data(iRowCnt1, sNameOnRpt, sSklstEnd
sDNEnd, True, iFreq, iLoopCnt)
sAddress = Range(sAgentAddress & ":"
sSklstEnd).Find(sNameOnRpt).Address
iLoopCnt = iLoopCnt + 1
Loop While Not Range(sAgentAddress & ":"
sSklstEnd).Find(sNameOnRpt) Is Nothing
End Selec
 
G

George Nicholson

Is it possible that Range(sAgentAddress & ":" & sSklstEnd).Find(sNameOnRpt)
returns nothing? That would certainly explain an ObjectVariable error when
you try to get Nothing's Address.

George Nicholson

Remove 'Junk' from return address.
 
G

George Nicholson

Except that "sAddress = Range (yada)" doesn't appear in his code that I can
see. However, "sAddress = Range (yada).ADDRESS" does appear, and that
results in a string, not an object, so using Set isn't necessary.
 
Top