Thanks Peter for help with my previous post.

Ok, I have this code below, however it doesn't seem to
recognize when there is an empty cell. I have tried
using cell <> "" and I get the same result. It seems to
think there is something in the cell. I only want the
code to execute if it finds a value in xCell. I have
also tried Val(cellref).text <>.

Any suggestion?

' Declarations
Dim qty As Cell
Dim prc As Cell
Dim extPrc As Cell
Dim ttl As Long
Dim tbl As Table
' Initialization
Set tbl = ActiveDocument.Tables(2)

For i = 2 To tbl.Rows.Count
Set qty = tbl.Cell(Row:=i, Column:=2)
Set prc = tbl.Cell(Row:=i, Column:=4)
Set extPrc = tbl.Cell(Row:=i, Column:=5)

If Val(prc.Range.Text) <> Null Then
ttl = Val(qty.Range.Text) * Val(prc.Range.Text)
extPrc.Range.Text = ttl
Else
extPrc.Range.Text = ""
End If

Next

Re: If statement does not recognize empty cell. by Jezebel

Jezebel
Thu Feb 19 21:27:24 CST 2004

An empty cell actually contains two characters: vbcr + chr(7). The simple
test for whether a cell is empty is

If len(xCell.range.text) > 2 then .... xCell is not empty





"Dustin I" <anonymous@discussions.microsoft.com> wrote in message
news:139bf01c3f75f$d3c4a6e0$a501280a@phx.gbl...
> Thanks Peter for help with my previous post.
>
> Ok, I have this code below, however it doesn't seem to
> recognize when there is an empty cell. I have tried
> using cell <> "" and I get the same result. It seems to
> think there is something in the cell. I only want the
> code to execute if it finds a value in xCell. I have
> also tried Val(cellref).text <>.
>
> Any suggestion?
>
> ' Declarations
> Dim qty As Cell
> Dim prc As Cell
> Dim extPrc As Cell
> Dim ttl As Long
> Dim tbl As Table
> ' Initialization
> Set tbl = ActiveDocument.Tables(2)
>
> For i = 2 To tbl.Rows.Count
> Set qty = tbl.Cell(Row:=i, Column:=2)
> Set prc = tbl.Cell(Row:=i, Column:=4)
> Set extPrc = tbl.Cell(Row:=i, Column:=5)
>
> If Val(prc.Range.Text) <> Null Then
> ttl = Val(qty.Range.Text) * Val(prc.Range.Text)
> extPrc.Range.Text = ttl
> Else
> extPrc.Range.Text = ""
> End If
>
> Next
>



Re: If statement does not recognize empty cell. by anonymous

anonymous
Thu Feb 19 23:03:24 CST 2004

Thanks!
>-----Original Message-----
>An empty cell actually contains two characters: vbcr +
chr(7). The simple
>test for whether a cell is empty is
>
>If len(xCell.range.text) > 2 then .... xCell is
not empty
>
>
>
>
>
>"Dustin I" <anonymous@discussions.microsoft.com> wrote
in message
>news:139bf01c3f75f$d3c4a6e0$a501280a@phx.gbl...
>> Thanks Peter for help with my previous post.
>>
>> Ok, I have this code below, however it doesn't seem to
>> recognize when there is an empty cell. I have tried
>> using cell <> "" and I get the same result. It seems to
>> think there is something in the cell. I only want the
>> code to execute if it finds a value in xCell. I have
>> also tried Val(cellref).text <>.
>>
>> Any suggestion?
>>
>> ' Declarations
>> Dim qty As Cell
>> Dim prc As Cell
>> Dim extPrc As Cell
>> Dim ttl As Long
>> Dim tbl As Table
>> ' Initialization
>> Set tbl = ActiveDocument.Tables(2)
>>
>> For i = 2 To tbl.Rows.Count
>> Set qty = tbl.Cell(Row:=i, Column:=2)
>> Set prc = tbl.Cell(Row:=i, Column:=4)
>> Set extPrc = tbl.Cell(Row:=i, Column:=5)
>>
>> If Val(prc.Range.Text) <> Null Then
>> ttl = Val(qty.Range.Text) * Val(prc.Range.Text)
>> extPrc.Range.Text = ttl
>> Else
>> extPrc.Range.Text = ""
>> End If
>>
>> Next
>>
>
>
>.
>