ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Array Help? (https://www.excelbanter.com/excel-programming/297370-array-help.html)

Carrie[_3_]

Array Help?
 
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!

Tom Ogilvy

Array Help?
 
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" wrote in message
...
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!



Norman Jones

Array Help?
 
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" wrote in message
...
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)?

Thanks in advance!





All times are GMT +1. The time now is 01:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com