• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Type mismatch error in macro

nikhil83

New Member
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
 
Hi Nikhil ,

There can be more than one reason for the error ; you should post what cname contains ( Range("E6") ) , and what the activecell on the Index tab contains when the penultimate line of code is executed.

If the activecell contains an error value , then ActiveCell.Value will generate an error.

Narayan
 
Back
Top