User form successfully ran but no results are showing

jvivo3

New Member
Joined
May 15, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
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:
TB1TB2TB3TB4TB5TB6TB7TB8CMB9CMB10CBM11CMB12CMB13CMB14CMB15CMB16CMB17CMB1CMB2CMB3CMB4CMB5CMB6CMB18CMB19CMB20Array 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
 

Attachments

  • 1715791599333.png
    1715791599333.png
    165.2 KB · Views: 7

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
VBA Code:
             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)

Your array that you are creating with the Array function is a 1-dimensional array, but any range of cells is a 2-dimentional array. You need to convert your 1D array to a 2D array to to transfer it to a range.

[NOT TESTED]

VBA Code:
        Dim Array1D As Variant
        Dim Array2D As Variant
        Dim Indx As Long

VBA Code:
                For Each id In arr                    '##loop over the array
                    Array1D = 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)
 
                    ReDim Array2D(1 To 1, 1 To UBound(Array1D) + 1)
                    For Indx = 0 To UBound(Array1D)
                        Array2D(1, Indx + 1) = Array1D(Indx)
                    Next i

                    c.Resize(1, UBound(Array1D) + 1).Value = Array2D

                    Set c = c.Offset(1)               '##next output row
                    Set Array1D = Nothing
                    Set Array2D = Nothing
                Next id
 
Upvote 0

Forum statistics

Threads
1,223,843
Messages
6,174,982
Members
452,598
Latest member
jeffreyp

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