Hi SH14, welcome to the forum.
Rather than selecting a cell, entering a formula and then copying/pasting the formula, you can do it in one step. The code below determines the last used row in column H on Sheet1 (variable LR1) as well as the last used row in column A on the active sheet (variable LR2). It then puts your COUNTIF formula in column C of the active sheet from C2:C?, where ? is the same as LR2 (last used row in column A).
Sub test()
Dim LR1 As Long, LR2 As Long
LR1 = Sheets("Sheet1").Range("H" & Rows.Count).End(xlUp).Row
LR2 = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
Range("C2:C" & LR2).Formula = "=COUNTIF(Sheet1!$H$2:$H$" & LR1 & ",A2)"
End Sub
Hope that helps!
Bookmarks