learningthings
New Member
- Joined
- Oct 29, 2021
- Messages
- 35
- Office Version
- 365
- Platform
- Windows
I have a Userform that inputs data to a spreadsheet labelled ("Sales")
Now, sometimes, a sale can be paid for by two methods of payment (i.e. Cash and Credit)
The way I have the system set up is that if there are two methods of payment, the transaction is recorded under the "Sales" tab twice with the same ID number with different methods of payment, once with cash, once with credit
Now, I want to be able to pull up the data from the sheet ("Sales") based on two criteria: the ID and the payment method.
This is what I would usually use - This is able to fill textboxes on the userform based on the sales ID :
This gives me the first result matching the sales ID. But I want to be able to use application.match for both .txtID and "Credit" under column 5
Now, sometimes, a sale can be paid for by two methods of payment (i.e. Cash and Credit)
The way I have the system set up is that if there are two methods of payment, the transaction is recorded under the "Sales" tab twice with the same ID number with different methods of payment, once with cash, once with credit
Now, I want to be able to pull up the data from the sheet ("Sales") based on two criteria: the ID and the payment method.
This is what I would usually use - This is able to fill textboxes on the userform based on the sales ID :
VBA Code:
Dim iRow As Long
With Me
On Error Resume Next
iRow = Application.Match(.txtID.Text, Worksheets("Sales").Columns(1), 0)
On Error GoTo 0
If iRow > 0 Then
frmSales.txtitem.Text = Worksheets("Sales").Cells(iRow, "B").Value
.frmSales.txtquantity.Text = Worksheets("Sales").Cells(iRow, "D").Value
frmSales.txttotal.Text = Worksheets("Sales").Cells(iRow, "C").Value
End If