Is it possible to keep this data all in the same row? This is an hourly count form, and all numbers entered into the form must show up in the worksheet (Database) in the same row for the date entered. regardless of time slot selected.
VBA Code:
Private Sub cmdReset_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want to Reset your counts", vbYesNo + vbInformation, "Hourly Space Counts")
If msgValue = vbNo Then Exit Sub
Call Reset
End Sub
Private Sub cmdSave_Click()
Dim msgValue As VbMsgBoxResult
msgValue = MsgBox("Do you want to save your counts?", vbYesNo + vbInformation, "Hourly Space Counts")
If msgValue = vbNo Then Exit Sub
Call Submit
End Sub
Private Sub UserForm_Activate()
Dim C As Boolean
Do
If C = True Then Exit Sub
ClockTextBox = Format(Now, "HH:MM:SS")
lblDate1 = Format(Date, "mm/d/yyyy")
DoEvents
Loop
End Sub
Private Sub UserForm_Initialize()
lblDate2 = Format(Date, "mmmm d, yyyy")
Call Reset
End Sub
'Module
Option Explicit
Sub Reset()
Dim iRow As Long
iRow = [CountA(Database!A:A)] 'idetifying the last row
With frmForm
.txtRowNumber.Value = ""
.lstDatabase.ColumnCount = 145
.lstDatabase.ColumnHeads = True
.lstDatabase.ColumnWidths = "125 ,91 ,91,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91 ,91,91,91,91,91,91"
If iRow > 1 Then
.lstDatabase.RowSource = "Database!A2: EO" & iRow
Else
.lstDatabase.RowSource = "Database!A2:EO2"
End If
End With
End Sub
Sub Submit()
Dim x(1 To 24, 1 To 145), i&, ii&, lRow&, s
With Sheets("Database")
lRow = .Cells(1).CurrentRegion.Rows.Count + 1
For i = 1 To 144 Step 6
s = IIf(s = "", "0000", Format(CLng(s) + 100, "0000"))
If frmForm.Controls("txt" & s & "ABC") <> vbNullString Then
ii = ii + 1
x(ii, 1) = frmForm.lblDate1
x(ii, i + 1) = frmForm.Controls("txt" & s & "ABC")
x(ii, i + 2) = frmForm.Controls("txt" & s & "ConRac")
x(ii, i + 3) = frmForm.Controls("txt" & s & "P4")
x(ii, i + 4) = frmForm.Controls("txt" & s & "P6")
x(ii, i + 5) = frmForm.Controls("txt" & s & "Valet")
x(ii, i + 6) = frmForm.Controls("txt" & s & "LotF")
End If
Next
.Cells(lRow, 1).Resize(24, 145) = x
.Columns(1).Resize(, 145).AutoFit
End With
'Unload frmForm
End Sub