Xlookup multiple criteria and range to last row

patriciacosta

New Member
Joined
Sep 19, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
ActiveCell.Formula2R1C1 = _
        "=XLOOKUP(RC[-3]&RC[4]&RC[10]&RC[12]&RC[21],'[Payscale payroll.xlsx]Payscale'!R2C[-8]:R689C[-8]&'[Payscale payroll.xlsx]Payscale'!R2C[-6]:R689C[-6]&'[Payscale payroll.xlsx]Payscale'!R2C[-5]:R689C[-5]&'[Payscale payroll.xlsx]Payscale'!R2C[-4]:R689C[-4]&'[Payscale payroll.xlsx]Payscale'!R2C[-3]:R689C[-3],'[Payscale payroll.xlsx]Payscale'!R2C[-2]:R689C[-2])"
    Range("I2").Select
    Selection.Copy
    Range("I3:I147").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Range("I2:I147").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("I2").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
End Sub

I'm learning how to use VBA so started using macro recorded. the attached formula works fine, but not always will go to row 689 or I147. I would like the range to go thru the last row, i tried add last row but it didnt work. If someone can help on this . thank you in advance
 
Last edited by a moderator:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

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