business_analyst
Board Regular
- Joined
- Jun 5, 2009
- Messages
- 99
Hello All,
So I am trying to pull several textboxes and a combobox from a userform onto an excel sheet. Here is my code:
This works, however, it is not pulling values from each textbox in the order that I would like. I am not sure if this is because of the count variable I am using or simply because of the logic involved in how ctl is used within the For loop. Is there a way I can specify a top down approach, where each textbox value is pulled in order from the first text box to the last?
Along with the order, there are large gaps in the worksheet, for instance the first 5 textbox values were pulled into cells A1:A5 as they should be, then there are about 8 empty cells before the other textbox values are show. I just dont understand the reasoning behind why this is happening.
So I am trying to pull several textboxes and a combobox from a userform onto an excel sheet. Here is my code:
Code:
Sub form_inputs()
Dim ctl As Control
Dim count As Integer
For Each ctl In frm_01.Controls
count = count + 1
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
Sheet5.Cells(count, 1) = ctl.Value
End If
Next ctl
MsgBox ("Inputs transferred")
End Sub
Along with the order, there are large gaps in the worksheet, for instance the first 5 textbox values were pulled into cells A1:A5 as they should be, then there are about 8 empty cells before the other textbox values are show. I just dont understand the reasoning behind why this is happening.