i have a user form that inserts job information in a worksheet (Date, Product Code, Lot Number, and Job Size) It all gets added correctly to my worksheet but i want to be able to rename my worksheet (with product code) with my userform instead of having to type it in again on the tab itself.
textbox for product code is txtProductCode
and the Code for the whole userform add is as follows:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("USE FOR NEW SHEET (2)")
'check for a part number
If Trim(Me.txtDate.Value) = "" Then
Me.txtDate.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
'copy the data to the database
ws.Cells(2, 4).Value = Me.txtDate.Value
ws.Cells(4, 4).Value = Me.txtProductCode.Value
ws.Cells(6, 4).Value = Me.txtLotNumber.Value
ws.Cells(4, 6).Value = Me.txtJobSize.Value
'clear the data
Me.txtDate.Value = ""
Me.txtProductCode.Value = ""
Me.txtLotNumber.Value = ""
Me.txtJobSize.Value = ""
Me.txtDate.SetFocus
End Sub
textbox for product code is txtProductCode
and the Code for the whole userform add is as follows:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("USE FOR NEW SHEET (2)")
'check for a part number
If Trim(Me.txtDate.Value) = "" Then
Me.txtDate.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
'copy the data to the database
ws.Cells(2, 4).Value = Me.txtDate.Value
ws.Cells(4, 4).Value = Me.txtProductCode.Value
ws.Cells(6, 4).Value = Me.txtLotNumber.Value
ws.Cells(4, 6).Value = Me.txtJobSize.Value
'clear the data
Me.txtDate.Value = ""
Me.txtProductCode.Value = ""
Me.txtLotNumber.Value = ""
Me.txtJobSize.Value = ""
Me.txtDate.SetFocus
End Sub