View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Kilmer[_2_] Bob Kilmer[_2_] is offline
external usenet poster
 
Posts: 71
Default declaring varibles looping probelm

recommend:

Dim Qty(1 To 28) 'an array
Dim i As Integer
For i = LBound(Qty) To UBound(Qty)
Qty(i) = Me.Controls("txtQty" & Cstr(i)).Value
Next i

'print 'em out
For i = LBound(Qty) To UBound(Qty)
Debug.Print Qty(i)
Next i

"l1075 " wrote in message
...
IM having trouble implementing the following code

Qty1 = txtQty1.Value
Qty2 = txtQty2.Value
...
...
Qty27 = txtQty27.Value
Qty28= txtQty28.Value

I have tried to use this code and it returns an error

For i = 1 To 28
Me.Controls("Qty" & i) = Me.Controls("txtQty" & i).Value
Next i

just wondering if there is a simplier way to do this

thanks


---
Message posted from http://www.ExcelForum.com/