I'm facing problem as I insert to my excel sheet from user form it recorded on both side of sheet.
I want it to be recorded on the sheet selected, how can I code it?
I want it to be recorded on the sheet selected, how can I code it?
VBA Code:
Sub Submit()
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database")
iRow = [Counta(Database!A:A)] + 1
With sh
.Cells(iRow, 1) = iRow - 1
.Cells(iRow, 2) = frmForm.txtDate.Value
.Cells(iRow, 3) = Now()
.Cells(iRow, 3).NumberFormat = "dd-mm-yyyy | HH:mm:ss"
.Cells(iRow, 4) = frmForm.cmbShift.Value
.Cells(iRow, 5) = frmForm.txtLeader.Value
.Cells(iRow, 6) = frmForm.txtAssistance.Value
.Cells(iRow, 7) = frmForm.txtLotNo.Value
.Cells(iRow, 8) = frmForm.txtSoNo.Value
.Cells(iRow, 9) = frmForm.txtBottleC.Value
.Cells(iRow, 10) = frmForm.txtBottleN.Value
.Cells(iRow, 11) = frmForm.txtTargetMan.Value
.Cells(iRow, 12) = frmForm.txtManNon.Value
.Cells(iRow, 13) = frmForm.txtManBorrow.Value
.Cells(iRow, 14) = frmForm.txtTotalMan.Value
.Cells(iRow, 15) = frmForm.txtPreform.Value
.Cells(iRow, 16) = frmForm.txtColour.Value
.Cells(iRow, 17) = frmForm.txtSetUp.Value
.Cells(iRow, 18) = frmForm.txtTimeStart.Value
.Cells(iRow, 19) = frmForm.txtTimeEnd.Value
.Cells(iRow, 20) = frmForm.txtTotalHours.Value
.Cells(iRow, 21) = frmForm.txtMaterialIn.Value
.Cells(iRow, 22) = frmForm.txtRejection.Value
.Cells(iRow, 23) = frmForm.txtProdOutput.Value
.Cells(iRow, 24) = frmForm.txtRemarks.Value
End With
Set sh = ThisWorkbook.Sheets("Summary")
iRow = [Counta('Summary'!A:A)] + 1
With sh
.Cells(iRow, 1) = iRow - 1
.Cells(iRow, 2) = frmForm.txtDate.Value
.Cells(iRow, 3) = Now()
.Cells(iRow, 3).NumberFormat = "dd-mm-yyyy | HH:mm:ss"
.Cells(iRow, 4) = frmForm.txtTotalMaterial.Value
.Cells(iRow, 5) = frmForm.txtMachineCap.Value
.Cells(iRow, 6) = frmForm.txtTotalOut.Value
.Cells(iRow, 7) = frmForm.txtTotalRej.Value
.Cells(iRow, 8) = frmForm.txtUtiliz.Value
.Cells(iRow, 9) = frmForm.txtOut.Value
.Cells(iRow, 10) = frmForm.txtRej.Value
End With
End Sub
Dropbox - File Deleted - Simplify your life
www.dropbox.com