MrExcel Publishing
Your One Stop for Excel Tips & Solutions

returning a range obj from function

Posted by Yu-Kuan on July 17, 2000 6:49 PM

Hi all,

This is probably a real easy question for all you excel wizards out there =)

I have a function that has the user select a range of input (e.g., A4:A10) as its output, which is then set to a range var inside the function. In the main sub, after calling this function, i want to point a range var to the output of this function, but for some reason am not able to. any ideas will be greatly appreciated.


Dim R as range

Set R = InputSigma(t) ' InputSigma(t) is the function that has the user choose the range.

I've checked InputSigma() - it works fine. it just appears that when I exit the function, the range var is lost and I cannot point R from the main sub to it.

please help!

thanks so much.


Posted by Ryan on July 17, 0100 7:20 PM

What is your code for the function?


Posted by Ivan Moala on July 17, 0100 9:16 PM


Dim R as range @ the Module level and not
@ the sub level.

Dim R as Range

Function InputSigma(t)

your function code

End Function

Sub yourroutine()

Set R = InputSigma(t) ' InputSigma(t)


End Sub


Posted by Yu-Kuan on July 17, 0100 10:33 PM

Never mind...I figured it out. Thanks anyways.