ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unhandled Exception Error (https://www.excelbanter.com/excel-programming/296986-unhandled-exception-error.html)

J

Unhandled Exception Error
 
I keep getting a strange error when I try loop through excel's cells and find one with cotaining no data. I get an unhandled exception of type 'System.Runtime.InteropServices.COMexception'.... Exception from HRESULT: 0x800A03EC. My code is as follows

D
I +=
If mExcel.Range("A5").Text = " " The
....do somethin
Loop While MyExcel.Range(strBoth).Value < "

The if statement is the line causing the error. I've tried multiple vartions of the loop. I've refrenced the COM microsoft excel 10.0 and am running Office XP pro. I also included Imports Microsoft.Office.Core. Thanks for any help. Any useful links/examples would also be greatly appreciated.

PS I've mananged to make it through the if statmet a few times but I 've also been getting various cast exception errors regarding mscorlib.dll.

TH[_3_]

Unhandled Exception Error
 
1. I += 1 does not compile on ExcelXP
2. You may be running beyond cell limits as I don't see where you loop
terminates before it may run beyond 65535 cells. This might be solved with
my next suggestion.
3. If looking for cells containing no data you cannot have a space between
your quotes. It needs to be: If mExcel.Range("A5").Text = ""

For Each C in Range("myRange")
If C.value="" then
...do something
End If
Next

Of course, you must define what range you're looking in.

TH

I'd do it like thisOn 5/1/04 19:16, in article
, "J"
wrote:

I keep getting a strange error when I try loop through excel's cells and find
one with cotaining no data. I get an unhandled exception of type
'System.Runtime.InteropServices.COMexception'.... Exception from HRESULT:
0x800A03EC. My code is as follows:
Do
I += 1
If mExcel.Range("A5").Text = " " Then
....do something
Loop While MyExcel.Range(strBoth).Value < " "

The if statement is the line causing the error. I've tried multiple vartions
of the loop. I've refrenced the COM microsoft excel 10.0 and am running
Office XP pro. I also included Imports Microsoft.Office.Core. Thanks for any
help. Any useful links/examples would also be greatly appreciated.

PS I've mananged to make it through the if statmet a few times but I 've also
been getting various cast exception errors regarding mscorlib.dll.




All times are GMT +1. The time now is 03:33 PM.

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