Excel Cell Read Error

J

Joe

I keep am automating the reading of an Excel spreadsheet and
keep getting an error message when I check to see if a cell is
blank. This is my code

For i = 1 To RowsUsed
If xlSheet.Cells(i, 12).Value = "" Then
BlankOrigFICO = BlankOrigFICO + 1
End If
Next

The error message that I get is "Conversion from string'''' to
'Double' is not valid'

Does anyone have any ideas about how I can avoid this error?

J
 
C

Cindy M.

Hi Joe,
I keep am automating the reading of an Excel spreadsheet and
keep getting an error message when I check to see if a cell is
blank. This is my code

For i = 1 To RowsUsed
If xlSheet.Cells(i, 12).Value = "" Then
BlankOrigFICO = BlankOrigFICO + 1
End If
Next

The error message that I get is "Conversion from string'''' to
'Double' is not valid'

Does anyone have any ideas about how I can avoid this error?
Which programming language are you using?

How about if you use 12).TEXT instead of Value?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17
2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
J

Jake

If this is not a calculated field then you may also be able to use the cell's
"Formula" property. I have found this much less problematic than either Text
or Value.

Jacob
 
L

Landon

Hi Cindy, I also experiencing the same problem with Joe.

I use MFC 4.2.

1. I am trying to check if the LAST ROW and both 2 ROWS after the LAST ROW
are consecutively empty, I will insert a new line on that LAST ROW.

2. I also want to ask if I want to check a sheet's name, does my code below
is correct?

Here is my code to check SHEET'S NAME and if a row is EMPTY or NOT:
lpDisp = sheets.GetItem( COleVariant( "January" ) );

ASSERT( lpDisp );
sheet.AttachDispatch( lpDisp );

lpDisp = sheet.GetRange( COleVariant( "A8" ), COleVariant( "A8" ) );
ASSERT( lpDisp );
range.AttachDispatch( lpDisp );
if( range.GetValue() == COleVariant( VT_EMPTY ) )
range.SetValue( COleVariant( "1/25/98" ) );

I've got an error compile on the line of if( range.GetValue().......):
Error C2668: 'COleVariant::COleVariant': Cannot solve the summons of the
overload function.

How to solve this?

Thank you.
 

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

Top