Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Blank Cell (Word XP)

    I'm using VBA to cycle through each cell in a table. If want to determine if the cell is blank. Print.Debug indicates that the ASCII value of the character (the cell marker) in an empty cell is 13. But if I text c.Range.Text = Chr$(13) that never proved true. Len(c.Range.Text) for a blank cell is 2; sometimes 4.

    What would be the most efficient way of determing whether a table cell is empty?

    Thanks,
    Richard Barrett

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Blank Cell (Word XP)

    If the length of the text is 4, the cell is probably not really blank, but it contains spaces and/or line ends/paragraph marks. If a cell is blank, it has length 2 (there are a hidden paragraph mark and a cell marker Chr(7) at the end of each cell).

    So if you want to test whether a cell is really blank (i.e. nothing has been entered in it), you can use

    If Len(C.Range.Text) = 2 Then

    If you want to test whether the cell "looks" blank, you'd have to analyze the contents.

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: Blank Cell (Word XP)

    Thank you. The length of 4 was when I was testing the last row of a one column table. Chr(7) is helpful to me... I didn't know what the cell marker was.

    This is a big help. Thanks again.
    Richard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •