Add multiple TextBox data to sheet

beman

New Member
Joined
Jan 25, 2017
Messages
8
Hi,

I want to add data from multiple textboxes to a sheet that.
The form has multiple lines containing product data, like part, description, location, qty
It also has a textbox where you can enter the qty you need and txtQtyAdd

If the txtQtyAdd textbox contains a value it should copy the data from the textboxes with the same number to a sheet in excel.

So if txtQtyAdd1 and txtQtyAdd3 contains a value (number), the code should copy the data from the below textboxes to the sheet

txtPart1
txtDescrAv1
txtLocAv1
txtQtyAdd1

txtPart3
txtDescrAv3
txtLocAv3
txtQtyAdd3

This is the code I have but it only copies the data from the last filled in textboxes, in this example only the textboxes ending with 3.

Code:
For i = 1 To 10
    
    If Controls("txtQtyAdd" & i).Value <> Empty Then
            Sheets("PickList").Range("A" & LastRowA + 1) = Controls("txtPartAv" & i).Text
            Sheets("PickList").Range("B" & LastRowA + 1) = Controls("txtDescrAv" & i).Text
            Sheets("PickList").Range("C" & LastRowA + 1) = Controls("txtLocAv" & i).Text
            Sheets("PickList").Range("D" & LastRowA + 1) = Controls("txtQtyAdd" & i).Text
    End If


Next i


Thanks for the help!

B.
 
The "LastRowA" variable does not seem to increase in the loop.
Perhaps the code for "LastRowA" should be within the loop !!!
 
Upvote 0
Hi MickG,

Thanks for the help!

No I have another issue, if one of the textboxes (txtQtyAdd) in the range is not filled in it puts in a blank line, so line 1,2 and 4 get filled as txtQtyAdd3 is empty.

Do you know how I can fix that?
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top