Try:
Option Explicit
'1. COUNTIF: Used to count the number of repetitions on each cell value (Item#). That'll be Column A in the attached example.
Sub Test1()
Dim lLR As Long
lLR = Range("C" & Rows.Count).End(xlUp).Row
Dim lLR_HA As Long
lLR_HA = Sheets("HA Data").Range("A" & Rows.Count).End(xlUp).Row
Range("K2:K" & lLR).Formula = _
"=COUNTIF($E$2:$E$" & lLR_HA & ",E2)"
End Sub
'2. INDEX & MATCH: Used to lookup and match 'Item#' and return 'HA#'. That'll be lookup Column A and match with Column B in Sheet#2, then return Column A from Sheet#2 to Column C.
Sub Test2()
Dim lLR As Long
lLR = Range("C" & Rows.Count).End(xlUp).Row
Dim lLR_HA As Long
lLR_HA = Sheets("HA Data").Range("A" & Rows.Count).End(xlUp).Row
Range("L2:L" & lLR).Formula = _
"=INDEX('HA Data'!$D$2:$D$" & lLR_HA & ",MATCH('Sample Data'!E2,'HA Data'!$E$2:$E$" & lLR_HA & ",0),1)"
End Sub
'1. COUNTIF: Used to count the number of repetitions on each cell value (Item#). That'll be Column A in the attached example.
Sub Test3()
ActiveCell.FormulaR1C1 = "=COUNTIF(R2C5:R640C5,RC[-6])"
Range("K2").Select
Selection.AutoFill Destination:=Range("K2:K" & Range("C" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
End Sub
'2. INDEX & MATCH: Used to lookup and match 'Item#' and return 'HA#'. That'll be lookup Column A and match with Column B in Sheet#2, then return Column A from Sheet#2 to Column C.
Sub Test4()
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=INDEX('HA Data'!R2C4:R45C4,MATCH('Sample Data'!RC[-7],'HA Data'!R2C5:R45C5,0),1)"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L" & Range("C" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
End Sub
Bookmarks