textbox counter probelm

L

l1075

I was wondering if it was possible to populate textboxes with a counte
value. I need to search through a column to find an ordernumber an
then populate a number of textboxes depending on how many times tha
order number matches.

Dim OrderNum As Variant
Dim Qty As Variant
Dim ItemId As Variant
Dim ItemDes As Variant

OrderNum = shtOrder.Range("B2:B100").Value
OrderNum = shtOrder.Application.WorksheetFunction.Transpose(OrderNum)

Qty = shtOrder.Range("F2:F100").Value
Qty = shtOrder.Application.WorksheetFunction.Transpose(Qty)

ItemId = shtOrder.Range("G2:G100").Value
ItemId = shtOrder.Application.WorksheetFunction.Transpose(ItemId)

ItemDes = shtOrder.Range("H2:H100").Value
ItemDes = shtOrder.Application.WorksheetFunction.Transpose(ItemDes)

Dim Counter As Integer
Counter = 1

For i = 1 To UBound(OrderNum)
If OrderNum(i) = purchase.Value Then
txtQty(Counter).Value = Qty(i)
txtItem(Counter).Value = ItemId(i)
txtDes(Counter).Value = ItemDes(i)
Counter = Counter + 1
End If
Next i

'It gives my an error when i use the counter variable

thank
 
T

Tom Ogilvy

Textboxes on a Userform:

Counter = 1
For i = 1 To UBound(OrderNum)
If OrderNum(i) = purchase.Value Then
me.controls("txtQty" & Counter).Value = Qty(i)
me.Controls("txtItem" & Counter).Value = ItemId(i)
me.controls("txtDes" & Counter).Value = ItemDes(i)
Counter = Counter + 1
End If
Next i

Assumes the textboxes are name
txtqty1 txtitem1 txtdes1
txtqty2 txtitem2 txtdes2
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top