Why is the following macro giving me a 'type mismatch' error on last statement ? INDIRECT(cname&""!G:G"") is supposed to return a coloumn in the sheet with name stored in cname.
Code:
Dim y As Integer
Dim cname As String
Sheets("Index").Select
cname = Range("e6").Value
ActiveCell.FormulaR1C1 = "=COUNTIFS(INDIRECT(cname&""!G:G""),""Y"",INDIRECT(cname&""!F:F""), Employee_db[Empl Name]])"
y = y + ActiveCell.Value