Return Max Value of Column X after Vlookup of Column A

uvela

New Member
Joined
Feb 18, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
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:

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.:)
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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