View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Variable Name Changes in Loop Operation

LiCal used his keyboard to write :
You could use a For...Next loop and use the counter like so...

* Dim i As Integer
* For i = 1 To 3
* * MsgBox "Day_" & CStr(i)
* Next 'i



I was trying to get the msgbox to show the Date not "Day_1" etc.


Ok, put the dates in an array and loop the array...

Dim sDates, vaDates, i As Integer
For i = 0 To 14 Step 7
sDates = sDates & "|" & Date + i
Next 'i
sDates = Mid$(sDates, 2)
vaDates = Split(sDates, "|")
For i = LBound(vaDates) To UBound(vaDates)
Debug.Print vaDates(i)
Next 'i

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc