Test for Empty, Null, "", 0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

TIA:

I am testing for contents of a cell (the data was imported from Access to
excel). The worksheet cell looks blank (no data) but when I test
IsEmpty in False and IsNull is False and cell="" is False

I see nothing but every test tells me something is there. If if test not Is
Empty is True.

If I test cell = 0 if get mismatch of data type (the field is Date format)

HELP...Thanks,

Joel
 
Mystery cells are always fun.

Say the cell is A1

What does LEN(A!) show ?
What does CODE(A1) show?
Does nothing appear in both the cell and formula bar?
 
It could contain a space(s) or a non-breaking space (chr(65)).

perhaps something like:

s = trim(cell.Value)
if len(s) = 0 or s like chr(65) then

or
s = Trim(cell.Value)
s = Replace(s,chr(65),"")
if len(s) = 0 then
 
Sorry, chr(65) should have been chr(160) in all cases.

chr(65) is "A" of course and was a mental glitch.
 
Gary:

Len returns 0
Code is #value errror

if I change code if len(a1) = 0 then...still doesn't work!!!

What else??

Joel
 
if len(a1) = 0 then

doesn't test the len of cell A1 - are you just writing pseudo code or . . .

Both of the results you reported are consistent with an empty cell. Perhaps
you have a logic error in your code.
 
Here's the code:

Sub OpnFiles()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object

except = InputBox("Enter Exceptions Value")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("c:\Copper") 'change directory
For Each objFile In objFolder.Files
If objFile.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open Filename:=objFolder.Path & "\" & objFile.Name

'do whatever
' Worksheets("qrycndataall").Activate
Range("A2").Select

If IsEmpty("A2") Then
Range("E2") = 0
Range("F2") = 0
GoTo a:
End If

If IsEmpty("A3") Then
Range("E2") = 1
Range("F2") = 1
GoTo a:
End If


Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
nra = Selection.Rows.Count
Range("e2") = nra
Range("B2").Select


Range("A2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="<" & except, Operator:=xlAnd
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
nrb = Selection.Rows.Count
Selection.AutoFilter
Range("f2") = nrb
a: Range("A2").Select
Workbooks(objFile.Name).Save
Workbooks(objFile.Name).Close True 'saves changes
End If
Next

End Sub
 
If IsEmpty("A2") Then
Range("E2") = 0
Range("F2") = 0
GoTo a:
End If

If IsEmpty("A3") Then
Range("E2") = 1
Range("F2") = 1
GoTo a:
End If

should be

If IsEmpty(Range("A2")) Then
Range("E2") = 0
Range("F2") = 0
GoTo a:
End If

If IsEmpty(Range("A3")) Then
Range("E2") = 1
Range("F2") = 1
GoTo a:
End If

After spotting those, I didn't check the rest of your code - so you might
want to make sure there are no more like that.
 
Tom:

Thanks to you for your time to spot the error...much appreciated.

Joel
 

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