R
Ranae
Good morning,
I am entering data into a worksheet with a userform. I need to enter the
exact same information into another worksheet (2010). Is there a way to do
this without having to write the same code for the second worksheet? Thank
you in advance.
Ranae
Dim Wbk As Workbook
Set Wbk = Workbooks("Reworklog")
Sheets("2006-2010").Select
Dim LastRow As Object
Set LastRow = Range("a65536").End(xlUp)
LastRow.Offset(1, 0) = Me.TBRecDate
LastRow.Offset(1, 1) = Me.TbDate
LastRow.Offset(1, 2) = Me.TbBoardType
LastRow.Offset(1, 3) = Me.cboboard
LastRow.Offset(1, 5) = Me.TbBatch
LastRow.Offset(1, 6) = Me.TbSN
LastRow.Offset(1, 7) = Me.cboDefectCode
LastRow.Offset(1, 8) = Me.cboProdSpec
LastRow.Offset(1, 9) = Me.cboCM
LastRow.Offset(1, 10) = Me.cboTech
LastRow.Offset(1, 11) = Me.TBreject
LastRow.Offset(1, 12) = Me.TBfinding
LastRow.Offset(1, 13) = Me.TBAction
LastRow.Offset(1, 14) = Me.TBLocation
LastRow.Offset(1, 15) = Me.cboResults
LastRow.Offset(1, 16) = Me.cboDisposition
LastRow.Offset(1, 21) = Me.cboPN1
LastRow.Offset(1, 22) = Me.cboPN2
LastRow.Offset(1, 23) = Me.cboPN3
LastRow.Offset(1, 24) = Me.cboPN4
LastRow.Offset(1, 20) = Me.TbSum
If Me.OptDbug1.Value Then
LastRow.Offset(1, 25) = Me.OptDbug1.Caption
ElseIf Me.OptDBug2.Value Then
LastRow.Offset(1, 25) = Me.OptDbug1.Caption
Else
If Me.OptDbug3.Value Then
LastRow.Offset(1, 25) = Me.OptDbug1.Caption
End If
End If
'Clear fields for next entry
Me.TbSN = ClearContents
Me.cboDefectCode = ClearContents
Me.TBreject = ClearContents
Me.TBfinding = ClearContents
Me.TBAction = ClearContents
Me.TBLocation = ClearContents
Me.OptDbug1 = ClearContents
Me.OptDBug2 = ClearContents
Me.OptDbug3 = ClearContents
Me.cboResults = ClearContents
Me.cboDisposition = ClearContents
Me.cboPN1 = ClearContents
Me.cboPN2 = ClearContents
Me.cboPN3 = ClearContents
Me.cboPN4 = ClearContents
Me.Tbcost1 = ClearContents
Me.Tbcost2 = ClearContents
Me.tbCost3 = ClearContents
Me.TbCost4 = ClearContents
Me.TbSum = ClearContents
Me.TbSN.SetFocus
End Sub
I am entering data into a worksheet with a userform. I need to enter the
exact same information into another worksheet (2010). Is there a way to do
this without having to write the same code for the second worksheet? Thank
you in advance.
Ranae
Dim Wbk As Workbook
Set Wbk = Workbooks("Reworklog")
Sheets("2006-2010").Select
Dim LastRow As Object
Set LastRow = Range("a65536").End(xlUp)
LastRow.Offset(1, 0) = Me.TBRecDate
LastRow.Offset(1, 1) = Me.TbDate
LastRow.Offset(1, 2) = Me.TbBoardType
LastRow.Offset(1, 3) = Me.cboboard
LastRow.Offset(1, 5) = Me.TbBatch
LastRow.Offset(1, 6) = Me.TbSN
LastRow.Offset(1, 7) = Me.cboDefectCode
LastRow.Offset(1, 8) = Me.cboProdSpec
LastRow.Offset(1, 9) = Me.cboCM
LastRow.Offset(1, 10) = Me.cboTech
LastRow.Offset(1, 11) = Me.TBreject
LastRow.Offset(1, 12) = Me.TBfinding
LastRow.Offset(1, 13) = Me.TBAction
LastRow.Offset(1, 14) = Me.TBLocation
LastRow.Offset(1, 15) = Me.cboResults
LastRow.Offset(1, 16) = Me.cboDisposition
LastRow.Offset(1, 21) = Me.cboPN1
LastRow.Offset(1, 22) = Me.cboPN2
LastRow.Offset(1, 23) = Me.cboPN3
LastRow.Offset(1, 24) = Me.cboPN4
LastRow.Offset(1, 20) = Me.TbSum
If Me.OptDbug1.Value Then
LastRow.Offset(1, 25) = Me.OptDbug1.Caption
ElseIf Me.OptDBug2.Value Then
LastRow.Offset(1, 25) = Me.OptDbug1.Caption
Else
If Me.OptDbug3.Value Then
LastRow.Offset(1, 25) = Me.OptDbug1.Caption
End If
End If
'Clear fields for next entry
Me.TbSN = ClearContents
Me.cboDefectCode = ClearContents
Me.TBreject = ClearContents
Me.TBfinding = ClearContents
Me.TBAction = ClearContents
Me.TBLocation = ClearContents
Me.OptDbug1 = ClearContents
Me.OptDBug2 = ClearContents
Me.OptDbug3 = ClearContents
Me.cboResults = ClearContents
Me.cboDisposition = ClearContents
Me.cboPN1 = ClearContents
Me.cboPN2 = ClearContents
Me.cboPN3 = ClearContents
Me.cboPN4 = ClearContents
Me.Tbcost1 = ClearContents
Me.Tbcost2 = ClearContents
Me.tbCost3 = ClearContents
Me.TbCost4 = ClearContents
Me.TbSum = ClearContents
Me.TbSN.SetFocus
End Sub