Dim exists Let exists = Evaluate("ISREF('" & <sheet name> & "'!A1)")
Dim amount As Long Dim lastRow As Long Dim r As Range Let lastRow = worksheet.Cells(Rows.Count, 1).End(xlUp).Row Set r = worksheet.Cells(<column letter> & "2:" & <column letter> & <lastRow>) Let amount = "=SUMPRODUCT(1/COUNTIF(r, r))"
worksheet.Rows("2:2").Select ActiveWindow.FreezePanes = True