I am new here, so I hope this is an appropriate thread / question for this forum. Thanks in advance for any input or help that you can offer.
I'm looking at using a userform for a quality technician to populate with dimensional data from our product. The userform is made up of multiple text boxes (textbox1 - 6) that I'd like to have ONLY numeric data entered into, and a combobox with a selection of geographical locations. The goal is to take these values and input them into rows of a separate worksheet ("Data") such that I can keep things organized and build graphs from. I have the data logging aspect functioning properly, but I'm having problems validating that the text box entries are numeric for the text box's, and if it is not, prompting the user to go back to the invalid entry and correct it. I'd like to have a message box to appear and request only numeric values when OK button is executed if they are in fact not Numeric. However, at the top of the userform there is a combobox that is populated with the locations of our facilities (Brazil, Fuzhou, Guelph, US, etc). I need to make sure that this is not empty when OK is executed as well; prompting the user to populate this combobox if indeed it is empty when selecting OK. What would this code look like, and where would it reside?
Private Sub CommandButton1_Click()
Dim LastRow As Object
Dim ws As Worksheet
Set ws = Worksheets("Data")
'Open the Storage Sheet for the Raw Data
Sheets("Data").Activate
'Find next empty row in "Data" sheet
Set LastRow = Sheets("Data").Range("A65536").End(xlUp)
'Insert data into cells
With LastRow
.Offset(1, 0) = ComboBox1.Text
.Offset(1, 1) = TextBox1.Value
.Offset(1, 2) = TextBox2.Value
.Offset(1, 3) = TextBox3.Value
.Offset(1, 4) = TextBox4.Value
.Offset(1, 5) = TextBox5.Value
.Offset(1, 6) = TextBox6.Value
End With
'Clear all the Entries Back to Blank
ComboBox1.Text = ""
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
'Set the data entry focus back to the first ComboBox1
ComboBox1.SetFocus
Unload UserForm1
End Sub
Thanks for your time!
Alex
I'm looking at using a userform for a quality technician to populate with dimensional data from our product. The userform is made up of multiple text boxes (textbox1 - 6) that I'd like to have ONLY numeric data entered into, and a combobox with a selection of geographical locations. The goal is to take these values and input them into rows of a separate worksheet ("Data") such that I can keep things organized and build graphs from. I have the data logging aspect functioning properly, but I'm having problems validating that the text box entries are numeric for the text box's, and if it is not, prompting the user to go back to the invalid entry and correct it. I'd like to have a message box to appear and request only numeric values when OK button is executed if they are in fact not Numeric. However, at the top of the userform there is a combobox that is populated with the locations of our facilities (Brazil, Fuzhou, Guelph, US, etc). I need to make sure that this is not empty when OK is executed as well; prompting the user to populate this combobox if indeed it is empty when selecting OK. What would this code look like, and where would it reside?
Private Sub CommandButton1_Click()
Dim LastRow As Object
Dim ws As Worksheet
Set ws = Worksheets("Data")
'Open the Storage Sheet for the Raw Data
Sheets("Data").Activate
'Find next empty row in "Data" sheet
Set LastRow = Sheets("Data").Range("A65536").End(xlUp)
'Insert data into cells
With LastRow
.Offset(1, 0) = ComboBox1.Text
.Offset(1, 1) = TextBox1.Value
.Offset(1, 2) = TextBox2.Value
.Offset(1, 3) = TextBox3.Value
.Offset(1, 4) = TextBox4.Value
.Offset(1, 5) = TextBox5.Value
.Offset(1, 6) = TextBox6.Value
End With
'Clear all the Entries Back to Blank
ComboBox1.Text = ""
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
'Set the data entry focus back to the first ComboBox1
ComboBox1.SetFocus
Unload UserForm1
End Sub
Thanks for your time!
Alex
Last edited: