arrays

ONIWE

New Member
Joined
Jun 29, 2010
Messages
25
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>
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,074
Office Version
365, 2010
Platform
Windows
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.
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,790
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.
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,790
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.
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,074
Office Version
365, 2010
Platform
Windows
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.
 

ONIWE

New Member
Joined
Jun 29, 2010
Messages
25
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.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,298
Messages
5,510,469
Members
408,791
Latest member
bwirth

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top