Hi,
Have problem with this.
I want to ensur that all textboxes are filled before saving the record to the last row+1 in Sheet1.
There are meny textboxes in userform (here is shown only 3).
Help with this please,
Have problem with this.
I want to ensur that all textboxes are filled before saving the record to the last row+1 in Sheet1.
There are meny textboxes in userform (here is shown only 3).
Help with this please,
VBA Code:
Private Sub cmbSaveRecord_Click()
Dim i As Long
Set sht = ThisWorkbook.Worksheets("Sheet1")
LastRow = sht.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
For Each ctrl In UserForm1.Controls
If TypeName(ctrl) = "TextBox" Then
If ctrl.Text = Empty Then
MsgBox ctrl.Name & " is empty"
ctrl.SetFocus
Exit For
End If
End If
Next ctrl
'-- save the record in Sheet1 if all textboxes are filled with data
Worksheets("Sheet1").Range("F" & LastRow).Value = TextBox1.Text
Worksheets("Sheet1").Range("G" & LastRow).Value = TextBox2.Text
Worksheets("Sheet1").Range("H" & LastRow).Value = TextBox3.Text
End Sub