Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Old style programming using Arrays

I have some data in a spreadsheet and want to do some complex things with it.
In the 'old days of GWBASIC' - before spreadsheets - I would set up the
following lines of programming:-

Dim table(40,60)
For i=1 to 40:for j=1 to 60
Read table(i,j)
next j:next i

Then I would analyse the data in the array.

I know that macros can handle the for/next loops but what are the equivalent
lines for setting up a 2 dimensional array and then getting the data from the
spreadsheet?

Any help would be appreciated.

Thanks

Under Pressure



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Old style programming using Arrays

Hi,

Try this.

'-----------------------------------
Dim MyTable As Variant
Dim A as long, B As long

With Worksheets("Sheet1")
MyTable = .Range("C5:H40").Value
End With

For a = 1 to ubound(MyTable,1)
For b = 1 to Ubound(MyTable,2)
'Your treatment for each data
X = MyTable(a,b)
Next
Next
'-----------------------------------


"Under Pressure" a écrit dans le message de
groupe de discussion : ...
I have some data in a spreadsheet and want to do some complex things with it.
In the 'old days of GWBASIC' - before spreadsheets - I would set up the
following lines of programming:-

Dim table(40,60)
For i=1 to 40:for j=1 to 60
Read table(i,j)
next j:next i

Then I would analyse the data in the array.

I know that macros can handle the for/next loops but what are the equivalent
lines for setting up a 2 dimensional array and then getting the data from the
spreadsheet?

Any help would be appreciated.

Thanks

Under Pressure

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Old style programming using Arrays

Another way is to just work on each cell in the range.

Dim myRng as range
dim myCell as range
dim wks as worksheet

set wks = activesheet

with activesheet
set myrng = .range("x99").resize(40,60) '40 rows by 60 columns
end with

for each mycell in myrng.cells
'do something with that cell
msgbox mycell.value & vblf & mycell.address(0,0)
next mycell



Under Pressure wrote:

I have some data in a spreadsheet and want to do some complex things with it.
In the 'old days of GWBASIC' - before spreadsheets - I would set up the
following lines of programming:-

Dim table(40,60)
For i=1 to 40:for j=1 to 60
Read table(i,j)
next j:next i

Then I would analyse the data in the array.

I know that macros can handle the for/next loops but what are the equivalent
lines for setting up a 2 dimensional array and then getting the data from the
spreadsheet?

Any help would be appreciated.

Thanks

Under Pressure


--

Dave Peterson
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
Programming style with worksheet functions - discussion invited pbart Excel Worksheet Functions 5 April 2nd 10 12:25 AM
How to stop style for col A changing to style of co D date vs $ Knowledge Seeker Setting up and Configuration of Excel 0 April 15th 08 03:26 PM
How do I change sheet notation from R1C1 style to A1 style in XL 2 Sherlock1506 Setting up and Configuration of Excel 1 December 5th 06 03:22 PM
How do I convert US style dates to European style? Neo Excel Discussion (Misc queries) 3 October 15th 06 02:24 PM
A1 style Range in programming [email protected] Excel Programming 3 September 1st 04 02:43 PM


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