W
whburling
A subroutine calls a function which is supposed to return data of type
"range". The
function fails with error 91. I suspect I am not differentiating a
"reference" to data from actual data. Here is the code:
Sub A()
Dim b as Range
Dim i as long
set b = BRange()
i = b.Columns.Count
end Sub
Function BRange() as Range
Dim aRange as Range
Dim i as long
set aRange = Application.InputBox(prompt:="select table",Type:=8)
i = aRange.columns.count
BRange = aRange
end Function
NOTES: Code fails when I attempt to assign aRange to BRange. I get a
run-time error of '91' - "object variable or with block variable not set".
I should point out that the Application.InputBox DOES return the range as I
CAN read at least one value through the variable, i, within the
function,BRange. (i can read the rest but kept this example simple by
omitting them)
please help me understand what I am doing wrong. I seem to be ignorant
about something and hence can't overcome this error
"range". The
function fails with error 91. I suspect I am not differentiating a
"reference" to data from actual data. Here is the code:
Sub A()
Dim b as Range
Dim i as long
set b = BRange()
i = b.Columns.Count
end Sub
Function BRange() as Range
Dim aRange as Range
Dim i as long
set aRange = Application.InputBox(prompt:="select table",Type:=8)
i = aRange.columns.count
BRange = aRange
end Function
NOTES: Code fails when I attempt to assign aRange to BRange. I get a
run-time error of '91' - "object variable or with block variable not set".
I should point out that the Application.InputBox DOES return the range as I
CAN read at least one value through the variable, i, within the
function,BRange. (i can read the rest but kept this example simple by
omitting them)
please help me understand what I am doing wrong. I seem to be ignorant
about something and hence can't overcome this error