Keeping Data by Date in the same row using an excel vba Form

Bugs65

New Member
Joined
Aug 26, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top