Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
3 Things
1. How could I only vlookup values on cell below active cell?
2. Also the vlookup does not work error 1004?
3. And the For Loop will not loop through all the cells??
1. How could I only vlookup values on cell below active cell?
2. Also the vlookup does not work error 1004?
3. And the For Loop will not loop through all the cells??
VBA Code:
Sub Dup_Part_Numbers()
'(TargetWorksheet As Worksheet)
Dim Rng As Range
Dim Cell As Variant
Dim r As Integer, c As Integer
Dim LRow As Long, LCol As Long
Dim ws As Worksheet
With Application
.EnableEvents = False
.ScreenUpdating = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With
Set ws = ActiveSheet
With ws
LRow = .Cells(Rows.Count, 13).End(xlUp).Row + 1
Set Rng = .Range("M" & LRow)
For Each Cell In Rng
On Error Resume Next
Cell.Value = _
Application.WorksheetFunction.VLookup(Cell.Offset(0, -11), _
.Range("C2:M" & LRow), 11, 0)
Next Cell
End With
With Application
.EnableEvents = True
.ScreenUpdating = True
.DisplayAlerts = True
.Calculation = xlCalculationAutomatic
End With
End Sub