I am very new to programming and this is my first thread ever so i apologies in advance for my ignorance. That being said, I have been working on making a excel document from snipits of code Ive found in different places that, once opened, displays a custom userform with a number of text boxes, combo boxes and even a few check boxes that, once submitted, will fill out the spreadsheet and hopefully eventually even populate a word document with the relevant information. As of this moment, if certain text boxes, combo boxes and check boxes are left blank and the userform is submitted, a separate message for each one will appear and say something specific like "Please fill the first name field!" and have an "ok" button at the bottom. my current problem is that though it shows the message box when there is an empty cell, if i hit the "ok" button the code will continue on and hide the userform (which i want to happen if all the boxes contain data) instead of allowing me to fill that blank text box and re-submit the userform. I've searched around a lot and tried a few different things but i think my lack of basic programming knowledge is holding me back. If anyone can give me a shove in the right direction it would be appreciated!
Here is the code I've come up with so far (any pointers on it in general would also be appreciated though i plan to eventually open a thread in the code review section once its working properly)
Private Sub CommandButton1_Click()
Dim rw As Integer
Dim ws As Worksheet
Set ws = Worksheets("sheet4")
rw = ws.Cells.Find(what:="*", searchorder:=xlRows, searchdirection:=xlPrevious, LookIn:=xlValues).Row + 1
If Trim(Me.TextBox2.Value) = "" Then
MsgBox "Please Fill The First Name Field!"
If Trim(Me.TextBox3.Value) = "" Then
MsgBox "Please Fill The Last Name Field!"
If Trim(Me.TextBox5.Value) = "" Then
MsgBox "Please Fill The Address Field!"
If Trim(Me.ComboBox1.Value) = "" Then
MsgBox "Please Select A Fabric Material Type!"
If Trim(Me.ComboBox2.Value) = "" Then
MsgBox "Please Select A Tax Location!"
If Trim(Me.TextBox6.Value) = "" Then
MsgBox "Please Fill The Track Space Feet Field!"
If Trim(Me.TextBox7.Value) = "" Then
MsgBox "Please Fill The Track Space Inches Field!"
If Trim(Me.TextBox8.Value) = "" Then
MsgBox "Please Fill The Track Length Feet Field!"
If Trim(Me.TextBox9.Value) = "" Then
MsgBox "Please Fill The Track Length Inches Field!"
ws.Cells(rw, 1).Value = Me.TextBox1.Value
ws.Cells(rw, 2).Value = Me.TextBox10.Value
ws.Cells(rw, 3).Value = Me.TextBox2.Value
ws.Cells(rw, 4).Value = Me.TextBox3.Value
ws.Cells(rw, 5).Value = Me.TextBox5.Value
ws.Cells(rw, 6).Value = Me.TextBox4.Value
ws.Cells(rw, 7).Value = Me.ComboBox2.Value
ws.Cells(rw, 8).Value = Me.ComboBox1.Value
ws.Cells(rw, 9).Value = Me.CheckBox1.Value
ws.Cells(rw, 10).Value = Me.CheckBox2.Value
ws.Cells(rw, 11).Value = Me.TextBox6.Value
ws.Cells(rw, 12).Value = Me.TextBox7.Value
ws.Cells(rw, 13).Value = Me.TextBox8.Value
ws.Cells(rw, 14).Value = Me.TextBox9.Value
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("\\SERVER\Documents\2020\Excell crap\test.docx")