HI There;
I am putting a form together and I want my data to start of row 12, but the data starts only on row16.
I am using a form, that when click save, apply the data tot eh spreadsheet named " Database"
This is the code I used.
Appreciate the help.
I am putting a form together and I want my data to start of row 12, but the data starts only on row16.
I am using a form, that when click save, apply the data tot eh spreadsheet named " Database"
This is the code I used.
VBA Code:
Sub reset()
Dim irow As Long
irow = Sheets("Database").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
' identifying the last row
With frmForm
.txtDate.Value = ""
.cmbShift.Clear
.cmbShift.AddItem "Day 1"
.cmbShift.AddItem "Day 2"
.cmbShift.AddItem "Day 3"
.cmbShift.AddItem "Day 4"
.cmbShift.AddItem "Day 5"
.cmbShift.AddItem "Day 6"
.cmbShift.AddItem "Day 7"
.cmbShift.AddItem "Day 8"
.cmbShift.AddItem "Day 9"
.cmbShift.AddItem "Day 10"
.cmbShift.AddItem "Night 1"
.cmbShift.AddItem "Night 2"
.cmbShift.AddItem "Night 3"
.cmbShift.AddItem "Night 4"
.cmbShift.AddItem "Night 5"
.cmbShift.AddItem "Night 6"
.cmbShift.AddItem "Night 7"
.cmbShift.AddItem "Night 8"
.cmbShift.AddItem "Night 9"
.cmbShift.AddItem "Night 10"
.txtTimeIn.Value = ""
.txtTimeOut.Value = ""
.cmbId.Clear
.cmbId.AddItem "2500-MOD-0001"
.cmbId.AddItem "2400-MOD-0001"
.cmbId.AddItem "2300-MOD-0001"
.cmbStow.Clear
.cmbStow.AddItem "WD-FWD"
.cmbStow.AddItem "WD-MID"
.cmbStow.AddItem "WD-AFT"
.cmbStow.AddItem "TWD-FWD"
.cmbStow.AddItem "TWD-MID"
.cmbStow.AddItem "TWD-AFT"
.cmbStow.AddItem "LH-FWD"
.cmbStow.AddItem "LH-MID"
.cmbStow.AddItem "LH-AFT"
.TxtComm.Value = ""
.lstdatabase.ColumnCount = 7
.lstdatabase.ColumnHeads = True
.lstdatabase.ColumnWidths = "90,90,90,90,110,90,220"
If irow > 1 Then
.lstdatabase.RowSource = "Database!A12:G" & irow
Else
.lstdatabase.RowSource = "Database!A12:G12"
End If
End With
End Sub
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, 1) = frmForm.txtDate.Value
.Cells(irow, 2) = frmForm.cmbShift.Value
.Cells(irow, 3) = frmForm.txtTimeIn.Value
.Cells(irow, 4) = frmForm.txtTimeOut.Value
.Cells(irow, 5) = frmForm.cmbId.Value
.Cells(irow, 6) = frmForm.cmbStow.Value
.Cells(irow, 7) = frmForm.TxtComm.Value
End With
End Sub
Sub Show_Form()
frmForm.Show
End Sub
Appreciate the help.
Last edited by a moderator: