Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 424
- Office Version
- 365
- Platform
- Windows
- Mobile
My VLookup code is not doing anything??
VBA Code:
Sub VLookup_Min()
Dim Wb As Workbook
Dim Src As Worksheet, Des As Worksheet
Dim SrcLRow As Long, DesLRow
Dim x As Variant
Dim SrcRng As Range, DesRng As Range
Set Wb = ThisWorkbook
Set Src = Wb.Worksheets("Intact Detail")
Set Des = Wb.Worksheets("Alton")
SrcLRow = Src.Range("A" & Rows.Count).End(xlUp).Row
DesLRow = Des.Range("A" & Rows.Count).End(xlUp).Row
Set DesRng = Des.Range("A2:A" & DesLRow)
Set SrcRng = Src.Range("A2:A" & SrcLRow)
Src.Range("O2:O" & SrcLRow).AutoFilter Field:=1, Criteria1:="<>"
For Each x In SrcRng.SpecialCells(xlCellTypeVisible)
On Error Resume Next
Src.Range("A" & x).Value = Application.WorksheetFunction.VLookup( _
Src.Range("O" & x).Value, DesRng, 8, False)
Next x
If Src.AutoFilterMode Then Src.AutoFilter.ShowAllData
End Sub