Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Please help - What am i doing wrong with this array?

I am trying to input random values from a range in excel into an array
What am I doing wrong?

From a damsel in distress!

----
Option Explicit
Option Base 1


Sub testing3()
Dim Vt() As Double
Dim j As Long
Dim i As Long

ReDim Preserve Vt(1 To 40)
For i = 1 To 40
j = Int(Rnd() * 1100)
Vt(i) = Worksheets("data").Cells(1, j)
Next i
End Su

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Please help - What am i doing wrong with this array?

j cannot be greater than 256, the maximum number of columns in Excel.

Alan Beban

acunnold < wrote:

I am trying to input random values from a range in excel into an array.
What am I doing wrong?

From a damsel in distress!

----
Option Explicit
Option Base 1


Sub testing3()
Dim Vt() As Double
Dim j As Long
Dim i As Long

ReDim Preserve Vt(1 To 40)
For i = 1 To 40
j = Int(Rnd() * 1100)
Vt(i) = Worksheets("data").Cells(1, j)
Next i
End Sub


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Please help - What am i doing wrong with this array?

Hi
see your other post. try replacing
j = Int(Rnd() * 1100)

with
j = Int(Rnd() * 10)+1

Note: j has to be between 1 and 256

--
Regards
Frank Kabel
Frankfurt, Germany

"acunnold " schrieb im
Newsbeitrag ...
I am trying to input random values from a range in excel into an

array.
What am I doing wrong?

From a damsel in distress!

----
Option Explicit
Option Base 1


Sub testing3()
Dim Vt() As Double
Dim j As Long
Dim i As Long

ReDim Preserve Vt(1 To 40)
For i = 1 To 40
j = Int(Rnd() * 1100)
Vt(i) = Worksheets("data").Cells(1, j)
Next i
End Sub


---
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
Whats wrong with this array formula Carl_B Excel Worksheet Functions 7 February 16th 10 09:39 PM
Sum + IF Array wrong sum ATL_Gabriel Excel Worksheet Functions 2 January 30th 09 01:21 AM
Array gives wrong answer Shu of AZ Excel Discussion (Misc queries) 1 November 11th 06 07:03 PM
What's wrong with my array formula M.Siler Excel Discussion (Misc queries) 4 May 27th 05 09:19 PM
whats wrong with my array? joshashcraft Excel Programming 2 September 9th 03 07:54 PM


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