Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Llurker
 
Posts: n/a
Default Confused about arrays and ranges in functions

Hello--

I am encountering difficulty working with arrays and ranges in worksheet
functions. Are arrays interchangeable with ranges in functions such as
Large, Index, and Match? If so, how would I specify a particular row in a
multi-dimensional array?

Example:

function minscores( byref myscores as range ) as range ' return new
values to the range when done
dim scores as variant
dim lowval as integer
scores=myscores ' creates 2xn scores array
lowval=worksheetfunction.large(scores, 1) ' get largest score
This returns a variety of errors depending on how I reference scores in the
function.
How can I refer to the correct row of scores in the line above?

Related question: If I can't use arrays in this fashion, then I have to work
with the range directly. Can I create a "virtual range" to work with so
that I don't have to find a work area in my spreadsheet to do calculations
in?

Many thanks for any insight you can provide.

Bonus question:
What I'm trying to do is highlight the three lowest scores (which might be
duplicated) in a 5-cell range.
I've been copying the range to an array and trying to use the above
functions, which gets very convoluted (the functions return the value of the
lowest number, not the index of the cell of the lowest number), and
ultimately doesn't work because of the array/range problem mentioned above.

dim lowscore(5) integer ' index of lowest scores
dim scores(1,5) as integer ' the input scores
dim i as integer
for i =1 to 5
scores(0,i)=(scores(1,i)+.01*i)*100 ' make each score different by adding
..01, .02, then multiply by 100 to get an integer
next i
for i=1 to 3
tmpval=worksheetfunction.large(lowscores( ),6-i) <---problem with
lowscores() in this line
lowscores(i)=worksheetfunction.match(tmpval, lowscores(), 0) <----problem
with lowscores() in this line
next i



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
nesting functions Gary Brown Excel Worksheet Functions 0 May 31st 05 11:32 PM


All times are GMT +1. The time now is 09:22 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"