I've recently learnt how to create userforms through articles, youtube videos and all the tremendously helpful information in this forum. thank you!
I have been working on a project to create a basic point of sale system for data capture. I am struggling to work out how to transfer all the listbox items from the first and second column to an individual row each in the excel spreadsheet at the click of one button.
The code I have is below
[VBA]Private Sub btnConfirm_Click()
Dim lRow As Long
Dim ws As Worksheet
Dim Item As Object
Set ws = Worksheets("CafeOrders")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
.Cells(lRow, 1).Value = Me.TextBoxDate.Value
.Cells(lRow, 4).Value = Me.txtTotal.Value
.Cells(lRow, 5).Value = Me.lPaymentMethod.List
.Cells(lRow, 2),Cells(1row + tSummary.Listcount -1,1)).Value = tSummary.List
'Clear input controls
txtTotal.Text = Clear
txtCashAmount.Text = Clear
This is the line that I am not sure of
[VBA] .Cells(lRow, 2),Cells(1row + tSummary.Listcount -1,1)).Value = tSummary.List[/VBA]
Originally I had
[VBA] .Cells(lRow, 2).Value = Me.tSummary.List[/VBA]
However this was only transferring the first line item from the first column of the list box to the excel cell.
I would like for each item in the first column of the listbox be to transferred to the next available row in column B of the spreadsheet, and
for each item in the second column of the listbox be to transferred to the next available row in column C of the spreadsheet, each item in a new row in excel.
Is this possible? Hope this is not outplace. Apologies if so - this is all very new to me.
Any help would be very much appreciated.
Thanks in advance