Lindsay5590
New Member
- Joined
- Aug 4, 2017
- Messages
- 1
Hi,
I am looking for assistance with my userform/code (I am not well versed in VBA but can get by), I had a userform where I submitted data concerning each person one at a time and my code to transfer this data to a worksheet worked perfectly as I was only doing one person at a time therefore after each time I clicked "submit" - my next entry would move to a new row.
However the process has changed and now I have 10 Combobox's that will be each persons name, with an accompanying text box where a value will be entered. What I am looking to do is once the form is complete and I click submit, all the combobox entries (name) will go into Column A, and the accompanying textboxes (values) into column B. And as this will be a daily input, when I do the same the next day, it doesn't overwrite the previous days but follows on.
My code at the moment transfers all the data onto one row, then the following submission goes onto the following row, meaning my names are in columns A, C, E, G and my values are in columns B, D, F , H and so on.....
Current Code:
Private Sub submitbutton_Click()
Dim emptyRow As Long
'Make Sheet2 active
Sheet2.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
If submittedby.Value = "" Then
MsgBox "Submitted By Section Incomplete"
Else
'Transfer information
Cells(emptyRow, 1).Value = DTPicker1.Value
Cells(emptyRow, 2).Value = Name1.Value
Cells(emptyRow, 3).Value = Name1a.Value
Cells(emptyRow, 2).Value = name2.Value
Cells(emptyRow, 3).Value = name2a.Value
Cells(emptyRow, 6).Value = name3.Value
Cells(emptyRow, 7).Value = name3a.Value
Cells(emptyRow, 8).Value = name4.Value
Cells(emptyRow, 9).Value = name4a.Value
Cells(emptyRow, 10).Value = name5.Value
Cells(emptyRow, 11).Value = name5a.Value
Cells(emptyRow, 12).Value = name6.Value
Cells(emptyRow, 13).Value = name6a.Value
Cells(emptyRow, 14).Value = name7.Value
Cells(emptyRow, 15).Value = name7a.Value
Cells(emptyRow, 16).Value = name8.Value
Cells(emptyRow, 17).Value = name8a.Value
Cells(emptyRow, 18).Value = name9.Value
Cells(emptyRow, 19).Value = name9a.Value
Cells(emptyRow, 20).Value = name10.Value
Cells(emptyRow, 21).Value = name10a.Value
End If
'unclick submit button with no action (-1 removes duplication)
With submitbutton
Me.submitbutton.Value = False - 1
End With
' stay on front page
Sheet3.Activate
End Sub
Any help that you could provide would definitely be appreciated !
I am looking for assistance with my userform/code (I am not well versed in VBA but can get by), I had a userform where I submitted data concerning each person one at a time and my code to transfer this data to a worksheet worked perfectly as I was only doing one person at a time therefore after each time I clicked "submit" - my next entry would move to a new row.
However the process has changed and now I have 10 Combobox's that will be each persons name, with an accompanying text box where a value will be entered. What I am looking to do is once the form is complete and I click submit, all the combobox entries (name) will go into Column A, and the accompanying textboxes (values) into column B. And as this will be a daily input, when I do the same the next day, it doesn't overwrite the previous days but follows on.
My code at the moment transfers all the data onto one row, then the following submission goes onto the following row, meaning my names are in columns A, C, E, G and my values are in columns B, D, F , H and so on.....
Current Code:
Private Sub submitbutton_Click()
Dim emptyRow As Long
'Make Sheet2 active
Sheet2.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
If submittedby.Value = "" Then
MsgBox "Submitted By Section Incomplete"
Else
'Transfer information
Cells(emptyRow, 1).Value = DTPicker1.Value
Cells(emptyRow, 2).Value = Name1.Value
Cells(emptyRow, 3).Value = Name1a.Value
Cells(emptyRow, 2).Value = name2.Value
Cells(emptyRow, 3).Value = name2a.Value
Cells(emptyRow, 6).Value = name3.Value
Cells(emptyRow, 7).Value = name3a.Value
Cells(emptyRow, 8).Value = name4.Value
Cells(emptyRow, 9).Value = name4a.Value
Cells(emptyRow, 10).Value = name5.Value
Cells(emptyRow, 11).Value = name5a.Value
Cells(emptyRow, 12).Value = name6.Value
Cells(emptyRow, 13).Value = name6a.Value
Cells(emptyRow, 14).Value = name7.Value
Cells(emptyRow, 15).Value = name7a.Value
Cells(emptyRow, 16).Value = name8.Value
Cells(emptyRow, 17).Value = name8a.Value
Cells(emptyRow, 18).Value = name9.Value
Cells(emptyRow, 19).Value = name9a.Value
Cells(emptyRow, 20).Value = name10.Value
Cells(emptyRow, 21).Value = name10a.Value
End If
'unclick submit button with no action (-1 removes duplication)
With submitbutton
Me.submitbutton.Value = False - 1
End With
' stay on front page
Sheet3.Activate
End Sub
Any help that you could provide would definitely be appreciated !