randomhause
New Member
- Joined
- Jun 12, 2015
- Messages
- 8
Hello!
I'm new to vba in excel and understanding the language & i need help with my user form
I have created a form that acts like a Log Form to track who goes into a room. In my form I have two command buttons that allow users to Submit Entry & Log Off. The Submit Entry button acts like a log-in button and Log Off button does just that, log them off.
Now I need my form to track the time & date the user entered a "Submit Entry" and when the user has "Log Out".
In my form I send the data from the User Form to a sheet in the same workbook. So I want this time & date to be recorded in this sheet.
As well, I need my sheet to only record those items (with date & time) that have been selected in the ListBox and keep all other entries listed. Currently, my form if I have to entries in my ListBox once I hit Log Out with a selected entry it will record all entries. So I need it to only record the one that is selected.
In addition, once I log out twice from my form all entries that where listed disappear from ListBox. I need the entries to stay in the listbox until it is selected and then the User click log out.
THANK YOU IN ADVANCE FOR YOUR HELP! Also, if you have any cool video tutorials on vba you can reference me to that would be great!
I'm new to vba in excel and understanding the language & i need help with my user form

I have created a form that acts like a Log Form to track who goes into a room. In my form I have two command buttons that allow users to Submit Entry & Log Off. The Submit Entry button acts like a log-in button and Log Off button does just that, log them off.
Now I need my form to track the time & date the user entered a "Submit Entry" and when the user has "Log Out".
In my form I send the data from the User Form to a sheet in the same workbook. So I want this time & date to be recorded in this sheet.
As well, I need my sheet to only record those items (with date & time) that have been selected in the ListBox and keep all other entries listed. Currently, my form if I have to entries in my ListBox once I hit Log Out with a selected entry it will record all entries. So I need it to only record the one that is selected.
In addition, once I log out twice from my form all entries that where listed disappear from ListBox. I need the entries to stay in the listbox until it is selected and then the User click log out.
THANK YOU IN ADVANCE FOR YOUR HELP! Also, if you have any cool video tutorials on vba you can reference me to that would be great!

Code:
'Form has function that when
'click object in excel it will show form
Sub RoundedRectangle2_Click()
frmLog.Show
End Sub
'This works properly
Code:
'frmLog(Code)
Private Sub cmdSubmit_Click() 'Adding txtbox data to listbox
With lstList
.AddItem txtVName.Value
.List(.ListCount - 1, 1) = txtCName.Value
.List(.ListCount - 1, 2) = txtPurpose.Value
End With
'Clearing txtbox after Submit Button clicked
Me.txtVName.Text = ""
Me.txtCName.Text = ""
Me.txtPurpose.Text = ""
'Set Focus on NameTextBox
txtVName.SetFocus
End Sub
Private Sub cmdLogOut_Click()
'To send data from User Form to Results Sheet
Dim ws As Worksheet
Set ws = Sheets("Results")
Dim nextAvailableRow As Long
Dim i As Long
For i = 0 To lstList.ListCount - 1
nextAvailableRow = ws.Range("A" & Rows.count).End(xlUp).Row + 1
ws.Range("A" & nextAvailableRow) = lstList.Column(0, i)
ws.Range("B" & nextAvailableRow) = lstList.Column(1, i)
ws.Range("C" & nextAvailableRow) = lstList.Column(2, i)
Next i
Me.Hide
'Clearing selected item in List Entry
If lstList.ListIndex >= 0 Then
lstList.RemoveItem lstList.ListIndex
End If
End Sub