Array Help?

C

Carrie

Hi- I need help reading two rows to an array. I have a list of names in the first row, columns G:p and a list of numbers in the 10th row, columns G:p. I want to read in the two rows, and (i think) transpose them before they are in the array so that they are actually two columns in the array. I next want to sort them and grab the 5 lowest numbers (and associated names). I'm fairly confident in VBA for access, but I'm getting a bit thrown off my this Excel stuff

I'm aware this is the 2nd time I've posted, but I'm in a bit of a time crunch. Thanks!
 
T

Tom Ogilvy

Dim varr as Variant
Dim rng as Range, rng1 as Range
set rng = Range("G1:p1")
set rng1 = range("G10:p10")
redim vArr(1 to 10, 1 to 2)
for i = 1 to 10
varr(i,1) = rng(1,i)
varr(i,2) = rng1(1,i)
Next

You said you had the sort down, so I guess that is what you need.


--
Regards,
Tom Ogilvy


Carrie said:
Hi- I need help reading two rows to an array. I have a list of names in
the first row, columns G:p and a list of numbers in the 10th row, columns
G:p. I want to read in the two rows, and (i think) transpose them before
they are in the array so that they are actually two columns in the array. I
next want to sort them and grab the 5 lowest numbers (and associated names).
I'm fairly confident in VBA for access, but I'm getting a bit thrown off my
this Excel stuff.
I'm aware this is the 2nd time I've posted, but I'm in a bit of a time
crunch. Thanks!
 
N

Norman Jones

Hi Carrie,

Assuming you have sorted your array (vArr) in ascending order and that your
first destination cell is B1, then try:

range("B1").Resize(5,2)=vArr

---
Regards,
Norman

Carrie said:
Thanks,
I've modified BubbleSort to get it to sort by my first column(numbers),
but also keep my second column (names). Now, how to i output to a 5 x 2
range in Excel, the 5 lowest numbers (and associated names)?
 
Top