0

I am getting object defined error while running the below code.Please help me debug the code.

For i = 5 To 11 Cells(i, G).Value = Application.WorksheetFunction.CountIf(Workbooks(1).Sheets(1).Range("H:H"), Cells(i, F).Value) + Application.WorksheetFunction.CountIf(Workbooks(1).Sheets(2).Range("H:H"), Cells(i, F).Value) Next i 

1 Answer 1

1

You need quotes around your columns, otherwise F and G are variables.

For i = 5 To 11 Cells(i, "G").Value = Application.WorksheetFunction.CountIf(Workbooks(1).Sheets(1).Range("H:H"), Cells(i, "F").Value) + Application.WorksheetFunction.CountIf(Workbooks(1).Sheets(2).Range("H:H"), Cells(i, "F").Value) Next i 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.