V
V
Viktor Budko2015-01-22 20:07:14
Visual Basic
Viktor Budko, 2015-01-22 20:07:14

VBA How to store the value of a statement into an array at each step of a loop?

Is there a command that can save the value of sStr(i) to the array at each step of the loop, so that as a result, the array avArr1 has as many elements as the number of steps the loop takes?

Dim sStr
Dim i, e
Dim avArr
Dim avArr1
sStr = Split(Me!ОрганРегУчета)
e = UBound(sStr)
i = 1
i = i + 1
Do
i = i + 1
???
Loop Until i = e
avArr = (sStr(1), s sStr(2))
avArr1 = ....

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Budko, 2015-01-23
@BudVic

Alexey Nemiro , thank you very much for your efforts)) Solution of the problem in a cycle:

Private Sub Кнопка()
Dim sStr() As String
sStr = Split(Me!Поле)
Dim avArr() As String
Dim i As Integer
For i = 3 To UBound(sStr) 'Где три начало отсчета'
If i = 3 Then 
ReDim avArr(0)
Else
ReDim Preserve avArr(UBound(avArr) + 1)
End If
avArr(UBound(avArr)) = sStr(i)
Next i
MsgBox Join(avArr, " ")
End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question