ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Type Mismatch (https://www.excelbanter.com/excel-programming/390446-type-mismatch.html)

Stout[_2_]

Type Mismatch
 
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


Tom Ogilvy

Type Mismatch
 
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


--
Regards,
Tom Ogilvy






"Stout" wrote:

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



Stout[_2_]

Type Mismatch
 
On May 31, 1:35 pm, Tom Ogilvy
wrote:
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

--
Regards,
Tom Ogilvy

"Stout" wrote:
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


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



All times are GMT +1. The time now is 10:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com