LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Using Loop to create Array

Another way using VBA similarly to what you are trying

ReDim v(1 To 1)
j = 1
For i = 1 To 100 Step 0.5
ReDim Preserve v(1 To j)
v(j) = "Level" & i
j = j + 1
Next
For j = LBound(v) To UBound(v)
Debug.Print v(j)
Next


--
HTH

Bob Phillips

"Nick Hebb" wrote in message
oups.com...
The problem is, it sees the contents of Left(k, len(k)-1) as one big
string. All those apostrophes are just elements of the string, not
separators.

An easier way to do it is to use the split() function:

For i = 1 To 100 Step 0.5
k = k & "Level " & i & ","
Next
'create the array
v = Split(Left(k, Len(k) - 1), ",")

For j = LBound(v) To UBound(v)
Debug.Print v(j)
Next

Also, I changed the <<k = k & """" & "Level" & """" & i line because
I couldn't quite understand what you were trying to do.



 
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
Loop through array of worksheets Andibevan[_2_] Excel Programming 4 May 19th 05 11:49 AM
How do I create a For loop within a For loop? Linking to specific cells in pivot table Excel Programming 2 January 24th 05 08:05 AM
Help with Loop / Array / Ranges Kathy - Lovullo Excel Programming 1 December 14th 04 02:59 PM
Assign Results from If...Then and Loop to an Array (VBA) a Excel Programming 5 July 29th 04 02:13 PM
Help -- Loop or Array? How to identify? zSplash Excel Programming 2 November 12th 03 05:05 AM


All times are GMT +1. The time now is 09:45 AM.

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"