MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 04:34 PM   #1
UALynn
 
Join Date: Mar 2004
Posts: 15
Default is it empty or not?

I have opened a text file into a workbook.
If I insert a formula in the workbook =len(B2) it returns a value of 0 for cells where I don't see any text.
However, in VBA when I do a len on the same cell I get a return of 252.
Code:
Debug.Print Len(.Range("B2"))
So I can't tell if the cell is empty using isempty because it thinks something is there.
UALynn is offline   Reply With Quote
Old Mar 30th, 2004, 05:52 PM   #2
NateO
MrExcel MVP
Admin
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,617
Default Re: is it empty or not?

Odd. Having some difficulty baking up a replication to the issue.

Use the Application object's clean() and trim() functions.
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO is offline   Reply With Quote
Old Mar 30th, 2004, 05:57 PM   #3
UALynn
 
Join Date: Mar 2004
Posts: 15
Default Re: is it empty or not?

I found a work around.
Open the txt file
Code:
strGrps = "C:\Whatever.txt"
    Set myBk = myXlObj.Workbooks.Open(Filename:=strGrps)
then do a saveas and convert to a xls file
Code:
 strGrps = "C:\Whatever.xls"
    myBk.SaveAs Filename:=strGrps, FileFormat:=xlWorkbookNormal
close it all up, set back to nothing, reopen the xls file and all works as it should.

Weirdness.
UALynn is offline   Reply With Quote
Old Mar 30th, 2004, 06:01 PM   #4
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 9,090
Default Re: is it empty or not?

That really is wierd but a nice workaround.

UALynn - - is the text file imported from some other software program, and if so what is that software program?
__________________
Tom Urtis
Tom Urtis is offline   Reply With Quote
Old Mar 30th, 2004, 06:01 PM   #5
NateO
MrExcel MVP
Admin
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,617
Default Re: is it empty or not?

That's not weird. It's the beauty of Excel!

Wrong thread eh.
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO is offline   Reply With Quote
Old Mar 30th, 2004, 06:06 PM   #6
UALynn
 
Join Date: Mar 2004
Posts: 15
Default Re: is it empty or not?

Quote:
UALynn - - is the text file imported from some other software program, and if so what is that software program?
Its an export from Lotus Notes.
UALynn is offline   Reply With Quote
Old Mar 30th, 2004, 06:34 PM   #7
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 9,090
Default Re: is it empty or not?

Thanks...good to know for future encounters with LN.
__________________
Tom Urtis
Tom Urtis is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 07:43 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.