I am building a VBA code that I need to lookup multiple values into another sheet. The second part to this is I have a table which I filter programmaticall y and I only want the vlookup to match the values in that table that are filtered and return a salary value. Based on that this is what i have come up with after doing some reading but obviously not working the way it should.
What i have posted is not the complete function, just the portion I am trying to get working.
FILTER APPLIED on DRFlag inside the table
value1 = EmployeeName
Value2 = objCode
Return value = BasePay
Sample Table
EmployeeName Title GradeStep Series IPNo MasterRecordNum ber FundCode OrgCode Program Project Task DRFlag ObjCode ObjDescription HoursWorked BasePay
Name 1 title1 5 11-1 n/a n/a 0000 000001 test testing 4 21 230 testing data 23 223.00
Name 1 title1 5 11-1 n/a n/a 0000 000001 test testing 4 22 231 testing data 23 253.00
Name 2 title1 2 10-9 n/a n/a 0000 000001 test testing 4 20 230 testing data 23 123.00
Name 3 title1 6 07-0 n/a n/a 0000 000001 test testing 4 21 234 testing data 23 23.00
What i have posted is not the complete function, just the portion I am trying to get working.
Code:
Set wks = Worksheets("tblINR144") 'define the sheet where the data I am looking for is
Set Rng = Wks.Range("H:W") ' Define the columns that identify the range.
Set SrcWks = Worksheets("Payroll")
Set Rng2 = SrcWks.Range("A4:B200")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets("PAYROLL").Select 'Currnet sheet where I have the value values that in need to find in payroll
For Each cl In Rng2
If z > 1 Then
s1 = SrcWks.Cells(z, 1).Value
s2 = SrcWks.Cells(z, 2).Value
' Call the Vlookup function to look up the rate of pay for the supplied employee name. This
' returns the value from the second column of the range A1:B8 within the current worksheet.
s3 = Application.WorksheetFunction.VLookup(s1 & s2, Rng.SpecialCells(xlCellTypeVisible), 10, False)
.......
........
....................
Next cl
FILTER APPLIED on DRFlag inside the table
value1 = EmployeeName
Value2 = objCode
Return value = BasePay
Sample Table
EmployeeName Title GradeStep Series IPNo MasterRecordNum ber FundCode OrgCode Program Project Task DRFlag ObjCode ObjDescription HoursWorked BasePay
Name 1 title1 5 11-1 n/a n/a 0000 000001 test testing 4 21 230 testing data 23 223.00
Name 1 title1 5 11-1 n/a n/a 0000 000001 test testing 4 22 231 testing data 23 253.00
Name 2 title1 2 10-9 n/a n/a 0000 000001 test testing 4 20 230 testing data 23 123.00
Name 3 title1 6 07-0 n/a n/a 0000 000001 test testing 4 21 234 testing data 23 23.00