I included both the formula and the value methods. For the first set, I inserted the formula. For the second set, I set the value.
Sub CountEntries()
Dim a As Range, d As Range, g As Range, cell As Range
Set a = Range("A2", Range("A" & Rows.Count).End(xlUp))
Set d = Range("D2", Range("D" & Rows.Count).End(xlUp))
Set g = Range("G2", Range("G" & Rows.Count).End(xlUp))
For Each cell In d
'cell.Offset(0, 1).Value2 = WorksheetFunction.CountIf(a, cell)
cell.Offset(0, 1).Formula = "=CountIf(" & a.Address & ", " & cell.Address & ")"
Next cell
For Each cell In g
cell.Offset(0, 1).Value2 = WorksheetFunction.CountIf(a, cell)
'cell.Offset(0, 1).Formula = "=CountIf(" & a.Address & ", " & cell.Address & ")"
Next cell
End Sub
Bookmarks