Select row with 2 different matching criteria

JAWAZ

New Member
Joined
Dec 21, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a workbook that keeps track of my business. The main worksheet is called “Dashboard” and everything shows up there in pivot tables. I have a worksheet named “Labor” that shows what employees have worked and what I owe them. The pivot table for “labor” on the “Dashboard” sheet, I have created a macro that I have attached to shapes called Pay. When clicked on the shape the macro finds the amount owed for that person in the “Labor” sheet in Column S and selects that cell and then offsets by 3 to the “Return” column that I enter the return amount. My problem is that if there are two different people, I owe the same amount to it just finds the first matching amount which may not be the correct person. I need a macro to match the amount with the name in the labor sheet.

Happy Holidays

Jim

Sub LBR_1()
' Works off of Pay Buttons
Application.ScreenUpdating = False
Worksheets("Labor").Visible = True
Application.CutCopyMode = False
Worksheets("Labor").UnProtect
Worksheets("Labor").Select
Dim lastrow As Long
With Sheets("Labor")
lastrow = .Cells(.Rows.Count, "S").End(xlUp).row
End With
lookupvalue = Worksheets("Dashboard").Range("F20").Value
lookuprange = Worksheets("Labor").Range("S1:S" & lastrow)
On Error GoTo ErrorMesageBox
MatchRowNumber = WorksheetFunction.Match(lookupvalue, lookuprange, 0)
Worksheets("Labor").Range("S" & MatchRowNumber).Select
ActiveCell.Offset(0, -3).Select
Application.ScreenUpdating = True
Exit Sub
ErrorMesageBox: MsgBox "This number is not found. Please go to the Labor Sheet to find the Problem"
Exit Sub
End Sub

1671467752045.png
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top