Type Mismatch

  • Thread starter Thread starter Stout
  • Start date Start date
S

Stout

This gives me a type mismatch in Excel 2007 but not in 2003

If Cells(MyRow, MyCol) = 0 Or IsEmpty(Cells(MyRow, MyCol)) Then

Does anyone know why?

Thanks.

Bill
 
What does Cells(MyRow,MyCol) contain when you get the type mismatch error.

If it contains an Excel Error Value, that can cause that problem (but I
would expect it in any version).

In Excel 97, comparing a string to a Number (zero in this case) would raise
a type mismatch - I don't have xl2007 to test, but maybe they when backwards
in of the fix to that problem.

You could try

If Cells(MyRow, MyCol).Text = "0" Or IsEmpty(Cells(MyRow, MyCol)) Then
 
What does Cells(MyRow,MyCol) contain when you get the type mismatch error.

If it contains an Excel Error Value, that can cause that problem (but I
would expect it in any version).

In Excel 97, comparing a string to a Number (zero in this case) would raise
a type mismatch - I don't have xl2007 to test, but maybe they when backwards
in of the fix to that problem.

You could try

If Cells(MyRow, MyCol).Text = "0" Or IsEmpty(Cells(MyRow, MyCol)) Then

Thanks man...that was it. It had errors...macros were not enabled.

I have another question now...I get a 1004 error on this line:

sheets(targetsheet).ChartObjects.Delete

Once again, only in 2007. I can comment it out and it seems to run
correctly but I can't find why this doesn't work.

Thanks again.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top