LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error with a For loop with arrays


Hello, I am trying to write the values of two arrays (one boolean and
the other integer of one dimension of 50 values each one) to a
worksheet.

the code i use is this:

For I = 0 to 10
Cells(1 + I, "A").Value = I +1
Cells(1 + I, "B").Value = Array_Bool(I)
Cells(1 + I, "C").Value = Array_Int(I)
Next I

The problem I get is that Excel gives me an error:

' Error '9' occurred in execution time. '
' Subindex out of interval '

(translated from spanish)

the third line is marked in yellow with the debug option, and if I mark
it as comment, then the same happens with the fourth line.

variables are declared this way:

Dim Array_Bool(50) As Boolean
Dim Array_Int(50) As Integer
Dim I As Integer

Also, it works if I manually write this:
Cells(25, 2).Value = Array_Bool(0)
Cells(26, 2).Value = Array_Bool(1)
Cells(27, 2).Value = Array_Bool(2)
Cells(28, 2).Value = Array_Bool(3)
Cells(29, 2).Value = Array_Bool(4)
Cells(30, 2).Value = Array_Bool(5)
Cells(31, 2).Value = Array_Bool(6)
Cells(32, 2).Value = Array_Bool(7)
Cells(33, 2).Value = Array_Bool(0)

Cells(25, 3).Value = Array_Int(0)
Cells(26, 3).Value = Array_Int(1)
Cells(27, 3).Value = Array_Int(2)
Cells(28, 3).Value = Array_Int(3)
Cells(29, 3).Value = Array_Int(4)
Cells(30, 3).Value = Array_Int(5)
Cells(31, 3).Value = Array_Int(6)
Cells(32, 3).Value = Array_Int(7)
Cells(33, 3).Value = Array_Int(0)



Shouldn't the first code and the second one produce the same result??


--
baldomero
------------------------------------------------------------------------
baldomero's Profile: http://www.excelforum.com/member.php...o&userid=25680
View this thread: http://www.excelforum.com/showthread...hreadid=397769

 
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
Index with 2 arrays returns error Rasoul Khoshravan Excel Worksheet Functions 2 October 21st 06 05:47 AM
reference 2 arrays in a For Loop Bruce Excel Programming 1 June 10th 05 08:45 AM
Help - Type mismatch when running loop with strings from arrays Marie J-son[_5_] Excel Programming 3 March 19th 05 08:36 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Error in loop Daniel Bonallack[_2_] Excel Programming 2 November 19th 03 07:10 PM


All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"