please help whith arrays there is a code

For i1 = x To xx

tekst(Tex) = Cells(i1, 1).Value ' must be array?

Tex = Tex + 1 ' increase array, if arrays this string do not need?

Next i1for each t in Tekst(Tex)

msgbox t

next tresult in msgbox must be

tekst1 = "bla bla bla"

tekst2 = "ajshf ag aeg"

......... etc.

tekstN = "....."

here's some sample code to start with:

dim tex(10)

tex(1)="testing"

tex(2)="text"

tex(3)="arrays"

tex(4)="goodbye"

i=0

for each t in (tex)

msgbox "tex "&i&" "&t

i=i+1

nextbut note that it reiterates msgboxes for the entire array of

"tex" (as declared, 10 elements) not just the four that are assigned values. the for-loop can also go like this:

for i=1 to 4

msgbox "tex "&i&" "&tex(i)

next

Thanks for reply. Reason is that array is udefined, it can be 10 and can be 100 according on xx value. And each tekst(tex) is a string value and it len can be greater than 40 simbols. its extract text from html files.

xx = Ubound(cells()) This will put the size of the array into xx.

If the size of the array is unknown at runtime you can use dynamic arrays.

If (xx Mod 5) = 0 Then

ReDim Preserve tekst(xx+5) As String

End If

This will increase the array length of texst() in multiples of five or whatever other number is appropriate.The ReDim Preseve is a useful function when using Arrays of undetermined length. I am not sure that it is available in VBA as it is taken from VB6.

Stuart

Ask Your Question

Weekly Poll