Hello, I am currently working on with a user form which has multipage tool, and each page has different tools such textboxes, combo boxes and checkboxes. This user form will be use as a data entry tool which will be populated into specific columns once the user click submit. Whenever I try to run the tool, no data is showing up to the sheet, and it doesn't show any error messages to notify me what's wrong with the code. In the data entry sheet, it has 32 columns which is designated for each textbox, combo box and checkbox.
TB= Textbox
CMB= Combo box
View attachment 111445
Designated Columns:
TB= Textbox
CMB= Combo box
View attachment 111445
Designated Columns:
TB1 | TB2 | TB3 | TB4 | TB5 | TB6 | TB7 | TB8 | CMB9 | CMB10 | CBM11 | CMB12 | CMB13 | CMB14 | CMB15 | CMB16 | CMB17 | CMB1 | CMB2 | CMB3 | CMB4 | CMB5 | CMB6 | CMB18 | CMB19 | CMB20 | Array of CMB "Data Item" | Array of CMB "Schedule" | Array of checkboxes "profits" | Array of checkboxes "capital" |
VBA Code:
Private Sub SUBMIT_Click()
Dim sh As Worksheet, msg As String, arr, c As Range, id
Dim profits As String, capitals As String, i As Long
'check for any empty required fields
If Len(TextBox1.Value) = 0 Then msg = msg & vbLf & " - Lipper ID"
If Len(msg) > 0 Then 'anything missing?
MsgBox "The following fields are required:" & msg, _
vbOKOnly + vbCritical, "Missing Information"
Else
'OK to write to sheet
Set sh = ThisWorkbook.Sheets("Bulk Loader File")
Set c = sh.Cells(Rows.Count, "A").End(xlUp).Offset(1) '##start adding here
arr = Split(TextBox1.Value, ",") '##split on comma to get an array
For i = 1 To 12
'if checkboxes are checked then add month name to appropriate string
If Me.Controls("Checkbox" & i).Value = "True" Then ' 1 to 12
AddWithComma profits, MonthName(i)
End If
If Me.Controls("Checkbox" & (12 + i)).Value = "True" Then ' 13 to 24
AddWithComma capitals, MonthName(i)
End If
Next i
For i = 21 To 35 Step 2 '## loop over comboboxes
dataItem = Me.Controls("ComboBox" & i).Value '## read combo values...
schedule = Me.Controls("ComboBox" & (i + 1)).Value
If Len(dataItem) > 0 Then '## any value selected?
For Each id In arr '##loop over the array
c.Resize(1, 30).Value = Array(Trim(id), TextBox2.Value, TextBox3.Value, TextBox4.Value, TextBox5.Value, TextBox6.Value, TextBox7.Value, TextBox8.Value, _
ComboBox7.Value, ComboBox8.Value, ComboBox9.Value, ComboBox10.Value, ComboBox11.Value, _
ComboBox12.Value, ComboBox13.Value, ComboBox14.Value, ComboBox15.Value, ComboBox16.Value, _
ComboBox17.Value, ComboBox1.Value, ComboBox2.Value, ComboBox3.Value, ComboBox4.Value, _
ComboBox5.Value, ComboBox6.Value, ComboBox18.Value, ComboBox19.Value, ComboBox20.Value, dataItem, schedule)
Set c = c.Offset(1) '##next output row
Next id
End If
Next i
MsgBox "Time Series Attributes Loaded", vbOKOnly + vbInformation, "Notification"
Unload Me
End If
End Sub