PC Review


Reply
Thread Tools Rate Thread

Create range in udf

 
 
Cresta
Guest
Posts: n/a
 
      4th Apr 2008
Hello
Is it possible for a UDF to dimension a named range to work with inside a UDF,
I need to create a named range so I can pass it into the sumifs function
withing the UDF. I have all the other args for the sumifs but arg1 is dynamic
and this is the bit i'm stuck on.

This is what I have so far.
....
Dim SearchColumn As Range
....
SearchColumn = ???? (To be Sheets(1).Range(cells(1,x%),cells(y%,x%))
....
result = WorksheetFunction.SumIfs(SearchColumn, Column1Range,
Column1Criteria, Column2Range, Column2Criteria)
....
ICTSumIf = result


Any ideas
Thanks





 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      4th Apr 2008
udf can reference (read) anything in any workbook, but has limited write
capabilities. I like to pass ranges in to UDF's.


=myfunction(A1:B4)
or
=myfunction(columns(1:3))

function myfunction(Myrange as Range)

for each cell in Myrange
.your code
next cell

result = WorksheetFunction.SumIfs(MyRange, Column2Criteria)



end function
"Cresta" wrote:

> Hello
> Is it possible for a UDF to dimension a named range to work with inside a UDF,
> I need to create a named range so I can pass it into the sumifs function
> withing the UDF. I have all the other args for the sumifs but arg1 is dynamic
> and this is the bit i'm stuck on.
>
> This is what I have so far.
> ...
> Dim SearchColumn As Range
> ...
> SearchColumn = ???? (To be Sheets(1).Range(cells(1,x%),cells(y%,x%))
> ...
> result = WorksheetFunction.SumIfs(SearchColumn, Column1Range,
> Column1Criteria, Column2Range, Column2Criteria)
> ...
> ICTSumIf = result
>
>
> Any ideas
> Thanks
>
>
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Range from Range dksaluki Microsoft Excel Misc 2 12th May 2010 12:35 AM
New range overwrites other range in create sheet macro wcollatz Microsoft Excel Programming 1 25th May 2009 08:52 PM
New range overwrites other range in create sheet macro wcollatz Microsoft Excel Programming 1 25th May 2009 05:45 PM
Create a new range from existing range Sachchi Microsoft Excel Programming 1 22nd Jul 2008 03:49 PM
Create/copy combo boxes in one range if condition is met in a different range LB Microsoft Excel Programming 4 30th Sep 2005 12:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 AM.