A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

search for empty cells in word tables



 
 
Thread Tools Display Modes
  #1  
Old October 9th, 2007, 01:45 AM posted to microsoft.public.word.tables
adgorn
external usenet poster
 
Posts: 25
Default search for empty cells in word tables

I have a document with many tables, including nested tables. I need to be
able to find all the cells that are empty since we may need to put a value in
there. It would be great to be able to go from empty cell to empty cell one
at a time. Any thoughts? Thanks.
--
Alan
  #2  
Old October 9th, 2007, 08:56 AM posted to microsoft.public.word.tables
macropod
external usenet poster
 
Posts: 1,231
Default search for empty cells in word tables

Hi Alan,

Here's some code to do the testing:

Sub TableTest()
Dim oTbl As Table
Dim oCel As Cell
With ActiveDocument.Range
For Each oTbl In .Tables
For Each oCel In oTbl.Range.Cells
If oCel.Range.Text = vbCr & Chr(7) Then MsgBox "Cell " & _
oCel.ColumnIndex & "," & oCel.RowIndex & " is empty."
Next
Next
End With
End Sub

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"adgorn" wrote in message ...
I have a document with many tables, including nested tables. I need to be
able to find all the cells that are empty since we may need to put a value in
there. It would be great to be able to go from empty cell to empty cell one
at a time. Any thoughts? Thanks.
--
Alan

  #3  
Old October 9th, 2007, 02:45 PM posted to microsoft.public.word.tables
adgorn
external usenet poster
 
Posts: 25
Default search for empty cells in word tables

That seems to be identifying the cells. What I really need is to have the
cursor jump from empty cell to the next empty cell rather than a message.
Possible?
--
Alan


"macropod" wrote:

Hi Alan,

Here's some code to do the testing:

Sub TableTest()
Dim oTbl As Table
Dim oCel As Cell
With ActiveDocument.Range
For Each oTbl In .Tables
For Each oCel In oTbl.Range.Cells
If oCel.Range.Text = vbCr & Chr(7) Then MsgBox "Cell " & _
oCel.ColumnIndex & "," & oCel.RowIndex & " is empty."
Next
Next
End With
End Sub

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"adgorn" wrote in message ...
I have a document with many tables, including nested tables. I need to be
able to find all the cells that are empty since we may need to put a value in
there. It would be great to be able to go from empty cell to empty cell one
at a time. Any thoughts? Thanks.
--
Alan


  #4  
Old October 9th, 2007, 09:17 PM posted to microsoft.public.word.tables
macropod
external usenet poster
 
Posts: 1,231
Default search for empty cells in word tables

Hi Alan,

Your first email said you needed to find the cell so that you could put something there. The code I posted identifies the cell, but
you didn't say what value you want to put there.

If you want to put something into a cell programmatically, you don't have to 'go' there - all you need is to replace the message box
code with whatever action you want to perform. For example:
If oCel.Range.Text = vbCr & Chr(7) Then oCel.Range.Text ="Hello World"
or
If oCel.Range.Text = vbCr & Chr(7) Then oCel.Range.Text = InputBox("Type your text")

If you actually need to select the cell so that you can do something with it manually, that can be done, but it means terminating
the code at that point:
If oCel.Range.Text = vbCr & Chr(7) Then
oCel.Select
Exit Sub
End I

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"adgorn" wrote in message ...
That seems to be identifying the cells. What I really need is to have the
cursor jump from empty cell to the next empty cell rather than a message.
Possible?
--
Alan


"macropod" wrote:

Hi Alan,

Here's some code to do the testing:

Sub TableTest()
Dim oTbl As Table
Dim oCel As Cell
With ActiveDocument.Range
For Each oTbl In .Tables
For Each oCel In oTbl.Range.Cells
If oCel.Range.Text = vbCr & Chr(7) Then MsgBox "Cell " & _
oCel.ColumnIndex & "," & oCel.RowIndex & " is empty."
Next
Next
End With
End Sub

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"adgorn" wrote in message ...
I have a document with many tables, including nested tables. I need to be
able to find all the cells that are empty since we may need to put a value in
there. It would be great to be able to go from empty cell to empty cell one
at a time. Any thoughts? Thanks.
--
Alan



 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:03 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.