I want to assign the inputs of a userform to variables in a new module once the user clicks submit.
I have read the following post : Passing variable from Form to Module in VBA
I believed I had written the code such that it followed the form set by the previous post but I am still getting an error:
Public Sub submit_click()
Dim user_name As String, occupation As String, state As String, city As String, married As Boolean, not_married As Boolean, num_kids As Integer
'General Information Inputs
user_name = firstname_textbox.Value
occupation = occupation_textbox.Value
state = state_textbox.Value
city = city_textbox.Value
married = married_option.Value
not_married = single_option.Value
num_kids = numchildren_textbox.Value
Unload Me
End Sub
This is the module I am using to check if I am passing the inputs over:
Public user_name As String, occupation As String, state As String, city As String, married As Boolean, not_married As Boolean, num_kids As Integer
Public salaried As Boolean, hourly As Boolean, monthly_hours As Double, salary As Double, wage_rate As Double, bonus As Double
Public retirement_account As String, retirement_account_contribution As Double, employer_match As Double, investing_amount As Double
Public Sub print_inputs()
Dim loc As Worksheet
Set loc = ThisWorkbook.Worksheets("Sheet1")
loc.Range("A1") = user_name.Value
End Sub
However, I get a "Invalid Qualifier" Error when trying to assign loc.range("A1") = user_name.Value
Am I assigning these inputs to variables incorrectly?