Good day all,
I am working with a code to copy a contractor details to a particular worksheet. On my first UserForm if you press the "Add Personnel" cmd button it takes you to a second userform "Contact & Qualification Details" on this UserForm I have 4 TextBoxes, when the data is entered I need this data to be copied to sheet "PAGE 2" in the relevant grid starting at A18 & then clear all textboxes for the next entry to be copied below the last, I have the code below & so far had no success, any assistance would be greatly appreciated, thank you all once again & have a great day - Marco
Private Sub cmdAddContractor_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PAGE 2")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Please enter Contractor Name?"
Exit Sub
End If
Sheets("PAGE 2").Unprotect Password:="000"
'copy the data to the database
ws.Cells(iColumn, "A").Value = Me.TextBox1.Value
ws.Cells(iColumn, "D").Value = Me.TextBox2.Value
ws.Cells(iColumn, "H").Value = Me.TextBox3.Value
ws.Cells(iColumn, "L").Value = Me.TextBox4.Value
'clear the data
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox1.Value = ""
Me.TextBox4.Value = ""
Me.TextBox1.SetFocus
Sheets("PAGE 2").Protect Password:="000", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Bookmarks