Hi, Can anyone help with a the following:
This code works but seems long winded and I don't want to write 'rng' to a sheet cell, but don't know how to reference within the .formula line
Dim shtM As Worksheet
Dim LastRowP As Long
Dim LastRowM As Long
Dim rng As String
Set shtM = Worksheets("Merged Data")
LastRowM = shtM.Cells(shtM.Rows.Count, Range("A1").Column).End(xlUp).Row
LastRowP = Worksheets("Sheet1").Cells(Worksheets("Sheet1").Rows.Count, Range("A1").Column).End(xlUp).Row
rng = ("Sheet1!$A$3:$C$" & LastRowP)
Range("AR2").Value = rng
Range("AP2:AP" & LastRowM).Formula = "=IFERROR(VLOOKUP(Merged_Data[@[AD User Display Name]],INDIRECT($AR$2) ,2,FALSE),0)"
what I'd like is something along the lines of...
Range("AP2:AP" & LastRowM).Formula = "=IFERROR(VLOOKUP([@[AD User Display Name]],Sheet1!$A$3:$C$"" & LastRowP & "",3,FALSE),0)"
Where the bold text is the bit I can't get working. Thanks in advance
This code works but seems long winded and I don't want to write 'rng' to a sheet cell, but don't know how to reference within the .formula line
Dim shtM As Worksheet
Dim LastRowP As Long
Dim LastRowM As Long
Dim rng As String
Set shtM = Worksheets("Merged Data")
LastRowM = shtM.Cells(shtM.Rows.Count, Range("A1").Column).End(xlUp).Row
LastRowP = Worksheets("Sheet1").Cells(Worksheets("Sheet1").Rows.Count, Range("A1").Column).End(xlUp).Row
rng = ("Sheet1!$A$3:$C$" & LastRowP)
Range("AR2").Value = rng
Range("AP2:AP" & LastRowM).Formula = "=IFERROR(VLOOKUP(Merged_Data[@[AD User Display Name]],INDIRECT($AR$2) ,2,FALSE),0)"
what I'd like is something along the lines of...
Range("AP2:AP" & LastRowM).Formula = "=IFERROR(VLOOKUP([@[AD User Display Name]],Sheet1!$A$3:$C$"" & LastRowP & "",3,FALSE),0)"
Where the bold text is the bit I can't get working. Thanks in advance