learningthings
New Member
- Joined
- Oct 29, 2021
- Messages
- 35
- Office Version
- 365
- Platform
- Windows
I am coding a cash register and have the following listbox load a "Register View".
It lists all of the transactions happening during one customer visit, for example a sale and a refund.
Every Sale is recorded on the "Sales" worksheet and every refund is recorded on the "Refund" Worksheet. The .lstRegister acts as a viewing panel.
Every Sale and Refund is linked to a unique ID number which is stored in column A of their respective worksheet. It is also stored in column A in the .lstRegister.
I want to be able to select a row from the listbox and be able to identify the matching row in either the sales or refund worksheet
Next, when clicking cmdEdit, I need frmSales to show up with prefilled information regarding that transaction i.e. fill .txtItemSold from column B of the correct row.
Let me know if there is information you need!
VBA Code:
Sub Reset_Register()
With frmRegister
Dim ws As Worksheet
Dim rng As Range
Dim MyArray
Set ws = Sheets("RegisterView")
Set rng = ws.Range("A1:I" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row)
With .lstRegister
.Clear
.ColumnHeads = False
.ColumnCount = rng.Columns.Count
'~~> create a one based 2-dim datafield array
MyArray = rng
'~~> fill listbox with array values
.List = MyArray
'~~> Set the widths of the column here. Ex: For 5 Columns
'~~> Change as Applicable
.ColumnWidths = "70;70;70;70;70;70;70;70;70"
.TopIndex = 0
.ListIndex = .ListCount - 1
End With
End With
End Sub
It lists all of the transactions happening during one customer visit, for example a sale and a refund.
Every Sale is recorded on the "Sales" worksheet and every refund is recorded on the "Refund" Worksheet. The .lstRegister acts as a viewing panel.
Every Sale and Refund is linked to a unique ID number which is stored in column A of their respective worksheet. It is also stored in column A in the .lstRegister.
I want to be able to select a row from the listbox and be able to identify the matching row in either the sales or refund worksheet
Next, when clicking cmdEdit, I need frmSales to show up with prefilled information regarding that transaction i.e. fill .txtItemSold from column B of the correct row.
Let me know if there is information you need!