Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Specify a target range in Function arguements
I would like to specify a target range in a vba function for excel and
redirect the results to the target range specified at the begining instead of using the function name, but keep givning me error, but was okay in Sub routine. It goes like this... Function Alpha(yTarget As Range, Other input arguments) ''' Resize yTarget based on the results to spit out and use For loop yTarget.Resize(m, n).name = "yTarget" For i = 1 To m For j = 1 to n yTarget.Cells(i, j) = results(i, j) Next j Next i I will appreciate if you can help me on this... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Specify a target range in Function arguements
User-Defined-Functions can only change the value of the cells that call them, so you'll need to keep
it a macro. HTH, Bernie MS Excel MVP wrote in message ups.com... I would like to specify a target range in a vba function for excel and redirect the results to the target range specified at the begining instead of using the function name, but keep givning me error, but was okay in Sub routine. It goes like this... Function Alpha(yTarget As Range, Other input arguments) ''' Resize yTarget based on the results to spit out and use For loop yTarget.Resize(m, n).name = "yTarget" For i = 1 To m For j = 1 to n yTarget.Cells(i, j) = results(i, j) Next j Next i I will appreciate if you can help me on this... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Specify a target range in Function arguements
Your function should be declared as to what object is returned and that
object assigned to the name of the function. For example: Function Alpha(yTarget As Range, Other input arguments) As Range .... .... Set Alpha = ytarget End Function Function Alpha(yTarget As Range, Other input arguments) ''' Resize yTarget based on the results to spit out and use For loop yTarget.Resize(m, n).name = "yTarget" For i = 1 To m For j = 1 to n yTarget.Cells(i, j) = results(i, j) Next j Next i -- Les Torchia-Wells " wrote: I would like to specify a target range in a vba function for excel and redirect the results to the target range specified at the begining instead of using the function name, but keep givning me error, but was okay in Sub routine. It goes like this... Function Alpha(yTarget As Range, Other input arguments) ''' Resize yTarget based on the results to spit out and use For loop yTarget.Resize(m, n).name = "yTarget" For i = 1 To m For j = 1 to n yTarget.Cells(i, j) = results(i, j) Next j Next i I will appreciate if you can help me on this... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"Too many arguements for this function"....ohh noooo.... | Excel Worksheet Functions | |||
OR Function with more than 30 arguements | Excel Discussion (Misc queries) | |||
If Function - Multiple Arguements? | Excel Worksheet Functions | |||
Target As Excel.Range or Target As Range | Excel Programming | |||
Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range) | Excel Programming |