arrays

ONIWE

New Member
Joined
Jun 29, 2010
Messages
27
Guys Help!!!!!!!!



i'm learning arrays and each time i copy an array code into the code sheet and execute, nothing happens. Can someone please tell em what i'm doing wrong.

this is an example:


<CODE>Sub FillArray() Dim curExpense(364) As Currency Dim intI As Integer For intI = 0 to 364 curExpense(intI) = 20 NextEnd Sub</CODE></PRE>
<CODE></CODE> </PRE>
<CODE>I'm sure I'm supposed to see some changes in my spreadsheet.</CODE></PRE>
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Guys Help!!!!!!!!



i'm learning arrays and each time i copy an array code into the code sheet and execute, nothing happens. Can someone please tell em what i'm doing wrong.

this is an example:


<code>Sub FillArray() Dim curExpense(364) As Currency Dim intI As Integer For intI = 0 to 364 curExpense(intI) = 20 NextEnd Sub</code>
<code></code>
<code>I'm sure I'm supposed to see some changes in my spreadsheet.</code>
Your array as you've dimensioned it has 364 elements with indicies starting at 0 and running through 363. So, your for -next statement should begin with
For intI = 0 to 363
Once you've fixed that you need to add some code to transfer the array elements to your spreadsheet. As it stands, the array is filled, but there are no further instructions which would cause your spreadsheet to change.
 
Upvote 0
Your array as you've dimensioned it has 364 elements with indicies starting at 0 and running through 363.

Hi Joe

The array as dimensioned has by default 365 elements with indicies starting at 0 and running through 364.

One could change the default to base 1 but then the array would have 364 elements with indices 1-364.
 
Upvote 0
Hi ONIWE

I don't see anything wrong with your code. But it does nothing.

You fill the array and then you do nothing with it.
 
Upvote 0
Hi Joe

The array as dimensioned has by default 365 elements with indicies starting at 0 and running through 364.

One could change the default to base 1 but then the array would have 364 elements with indices 1-364.
Bad arithmetic! Thanks for setting me straight PGC.
 
Upvote 0
Hi ONIWE

I don't see anything wrong with your code. But it does nothing.

You fill the array and then you do nothing with it.


That is exactly my point. How do I make use of the code. I got that code from the MS Excel help ....see below:

To set the value of an individual element, you specify the element's index. The following example assigns an initial value of 20 to each element in the array.

Sub FillArray()
Dim curExpense(364) As Currency
Dim intI As Integer
For intI = 0 to 364
curExpense(intI) = 20
Next
End Sub



if its not meant to do anything can someone please send me a sample one and two dimensional array that translates to something in the spreadsheet. Thanks guys.
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,159
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top