Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Unknown element array

Hi, I am trying to create an array that starts with a calculation and
then assigns that variable to the first element of the array. From
there the loop attempts to generate each suceeding element of the
array based on the previous element and some simple algebra. Let's say
that input3 generates a number that equals 2540. From there i redim
the table, assign input3 to the first element and proceed to generate
the array with the condition that Tble(rw) is less then 2550. I am
pretending that i don't know how many elements in the array it will
take to get to 2550, otherwise it would be easy. If this sounds kind
of ridiculous, I am really trying to use this as an example for when i
really won't know the number of elements to get to a given criteria.
If anyone has any ideas id appreciate it. Below is what i have so far.
Thanks

Sub Test()
Dim Input1, Input2, Input3, Box As Double
Dim Tble() As String
Dim rw, x, y As Integer

Input1 = Cells(1, 1).Value
Input2 = Cells(2, 1).Value

Input3 = Input1 * Input2

Cells(3, 1).Value = Input3

ReDim Preserve Tble(rw)
Tble(0) = Input3
rw = 1
Do
Tble(rw) = Tble(rw - 1) + 1
Loop While Tble(rw) <= 2550

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Unknown element array

Before we get to the Array thing most of your varaibles are not of the type
you think they are. Most of them are variants. Check out this link...

http://www.cpearson.com/excel/variables.htm

Now on to the arrays. Here is a simple example...

Sub test()
Dim ary() As Long
Dim lng As Long

lng = 0
ReDim ary(0)
ary(lng) = lng
Do While lng < 10
lng = lng + 1
ReDim Preserve ary(lng)
ary(lng) = ary(lng - 1) + 1
Loop
End Sub
--
HTH...

Jim Thomlinson


" wrote:

Hi, I am trying to create an array that starts with a calculation and
then assigns that variable to the first element of the array. From
there the loop attempts to generate each suceeding element of the
array based on the previous element and some simple algebra. Let's say
that input3 generates a number that equals 2540. From there i redim
the table, assign input3 to the first element and proceed to generate
the array with the condition that Tble(rw) is less then 2550. I am
pretending that i don't know how many elements in the array it will
take to get to 2550, otherwise it would be easy. If this sounds kind
of ridiculous, I am really trying to use this as an example for when i
really won't know the number of elements to get to a given criteria.
If anyone has any ideas id appreciate it. Below is what i have so far.
Thanks

Sub Test()
Dim Input1, Input2, Input3, Box As Double
Dim Tble() As String
Dim rw, x, y As Integer

Input1 = Cells(1, 1).Value
Input2 = Cells(2, 1).Value

Input3 = Input1 * Input2

Cells(3, 1).Value = Input3

ReDim Preserve Tble(rw)
Tble(0) = Input3
rw = 1
Do
Tble(rw) = Tble(rw - 1) + 1
Loop While Tble(rw) <= 2550


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Unknown element array

Are there any ideas here that could help?

Sub Demo()
Dim v()
Dim StartNumber As Long
Dim UpperLimit As Long
Dim NumberItems As Long
Dim j As Long

StartNumber = 2540
UpperLimit = 2550
NumberItems = UpperLimit - StartNumber + 1
ReDim v(1 To NumberItems)
v(1) = StartNumber
For j = 2 To NumberItems
v(j) = v(j - 1) + 1
Next j
End Sub

--
HTH :)
Dana DeLouis


wrote in message
ups.com...
Hi, I am trying to create an array that starts with a calculation and
then assigns that variable to the first element of the array. From
there the loop attempts to generate each suceeding element of the
array based on the previous element and some simple algebra. Let's say
that input3 generates a number that equals 2540. From there i redim
the table, assign input3 to the first element and proceed to generate
the array with the condition that Tble(rw) is less then 2550. I am
pretending that i don't know how many elements in the array it will
take to get to 2550, otherwise it would be easy. If this sounds kind
of ridiculous, I am really trying to use this as an example for when i
really won't know the number of elements to get to a given criteria.
If anyone has any ideas id appreciate it. Below is what i have so far.
Thanks

Sub Test()
Dim Input1, Input2, Input3, Box As Double
Dim Tble() As String
Dim rw, x, y As Integer

Input1 = Cells(1, 1).Value
Input2 = Cells(2, 1).Value

Input3 = Input1 * Input2

Cells(3, 1).Value = Input3

ReDim Preserve Tble(rw)
Tble(0) = Input3
rw = 1
Do
Tble(rw) = Tble(rw - 1) + 1
Loop While Tble(rw) <= 2550



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
Counting Array element asingh Excel Worksheet Functions 4 April 12th 10 03:30 PM
Permutations of an array element < to a value Bruce Excel Worksheet Functions 3 January 31st 06 04:00 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
Array element Andrea[_8_] Excel Programming 5 December 7th 04 08:24 PM


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