Hello,
I have a workbook with 2 sheets, "ProgramMasterList" and "urslabs". I'm trying to lookup the latest Date in column M in sheet "urslabs" and match the values into sheet "ProgramMasterList" in column V using column A as the lookup value in both sheets.
I'm using a vlookup to lookup the value of the latest date but am not sure of the best way to do so. I believe combining the MAX function with VLOOKUP would work but am not sure how to in VBA.
Below is what I have so far:
Any help would be appreciated.
Thanks.
I have a workbook with 2 sheets, "ProgramMasterList" and "urslabs". I'm trying to lookup the latest Date in column M in sheet "urslabs" and match the values into sheet "ProgramMasterList" in column V using column A as the lookup value in both sheets.
I'm using a vlookup to lookup the value of the latest date but am not sure of the best way to do so. I believe combining the MAX function with VLOOKUP would work but am not sure how to in VBA.
Below is what I have so far:
VBA Code:
Sub lookuptestdate()
Dim authorWs As Worksheet, detailsWs As Worksheet
Dim authorsLastRow As Long, detailsLastRow As Long, x As Long
Dim dataRng As Range
Set authorWs = ThisWorkbook.Worksheets("ProgramMasterList")
Set detailsWs = ThisWorkbook.Worksheets("urslabs")
authorsLastRow = authorWs.Range("A" & Rows.Count).End(xlUp).Row
detailsLastRow = detailsWs.Range("A" & Rows.Count).End(xlUp).Row
Set dataRng = detailsWs.Range("A1:W" & detailsLastRow)
For x = 2 To authorsLastRow
On Error Resume Next
authorWs.Range("V" & x).Value = Application.WorksheetFunction.VLookup( _
authorWs.Range("A" & x).Value, dataRng, 13, False)
Next x
End Sub
Any help would be appreciated.
Thanks.