Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default data from a sheet to a matrix

Dear Friends,

how can save data from an excel sheet into a two dimensional array i
order to perform for ... next i operations?
Out of your experience is it memory wise better to store data in V
variables and work with them or to work directly with the spreadshee
with Range("").Select etc. commands?

Additionally, is there a way to speed up the vlookup operation?

Thank you in advance

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default data from a sheet to a matrix

banavas < wrote:

Dear Friends,

how can save data from an excel sheet into a two dimensional array in
order to perform for ... next i operations?
Out of your experience is it memory wise better to store data in VB
variables and work with them or to work directly with the spreadsheet
with Range("").Select etc. commands?

Additionally, is there a way to speed up the vlookup operation?

Thank you in advance.


---
Message posted from http://www.ExcelForum.com/

Not sure what you mean by "memory wise", but it's certainly likely to be
faster using arrays.

Alan Beban
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default data from a sheet to a matrix

Dim vArr as Variant

vArr = Range("A1:B4")
for i = lbound(varr,1) to ubound(varr,1)
for j = lbound(varr,2) to ubound(varr,2)
msgbox "vArr(" & i & ", " & j & ") = " & varr(i,j)
next
Next


Note that you must pick up the values with a variant variable. In excel
2000 and later you can declare

Dim vArr() as Variant

In xl97 and earlier, you can not use the () in the declaration.

If it is a single column, you can use application.Transpose to get a one
dimensional array

vArr = Application.Transpose( Range("A1").Resize(10,1).Value)
for i = lbound(varr) to ubound(varr)
msgbox i & ", " & varr(i)
Next

If it is a single row, use Transpose twice. Otherwise both will come in a a
2D array with one dimension 1 to 1. Arrays built this way always have a
lower bound of 1.

Vlookup seems pretty fast. You could try passing an array as the second
argument.

Whether to loop a range or grab it in an array usually depends on what you
want to do.

--
Regards,
Tom Ogilvy


"banavas " wrote in message
...
Dear Friends,

how can save data from an excel sheet into a two dimensional array in
order to perform for ... next i operations?
Out of your experience is it memory wise better to store data in VB
variables and work with them or to work directly with the spreadsheet
with Range("").Select etc. commands?

Additionally, is there a way to speed up the vlookup operation?

Thank you in advance.


---
Message posted from http://www.ExcelForum.com/



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
Extracting Matrix Data ejack Excel Discussion (Misc queries) 3 March 29th 09 08:59 AM
Extracting data from a product matrix tarheelfan Excel Discussion (Misc queries) 0 March 25th 09 08:58 PM
Manipulating a matrix of data Magenta Excel Discussion (Misc queries) 3 February 5th 08 05:48 AM
Plot data from column to matrix Torsbyn Excel Discussion (Misc queries) 0 November 29th 06 07:43 AM
Create a matrix from data in three column sa02000 Excel Discussion (Misc queries) 3 June 28th 06 02:25 AM


All times are GMT +1. The time now is 07:21 AM.

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"