Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Too many arguements for this function"....ohh noooo.... dim Excel Worksheet Functions 3 October 10th 07 07:58 AM
OR Function with more than 30 arguements James T Excel Discussion (Misc queries) 4 May 12th 06 01:36 AM
If Function - Multiple Arguements? andyp161 Excel Worksheet Functions 4 February 1st 06 10:18 AM
Target As Excel.Range or Target As Range Piranha[_5_] Excel Programming 2 June 3rd 05 03:49 PM
Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range) Kevin McCartney Excel Programming 3 April 15th 05 01:51 PM


All times are GMT +1. The time now is 09:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"