Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

how to fill all cells that are empty in a table with a hyphen?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gil Carter - 13 Feb 2005 21:49 GMT
Hi All,

How does one put a hyphen in all empty cells in a table?
tia
Gil

Some of my efforts are:
Sub a1()
'
'   a1 macro
'
'
   Selection.MoveRight Unit:=wdCell

Dim MyVar, MyCheck
MyCheck = IsNull(MyVar)    ' Returns False.

'MyVar = ""
'MyCheck = IsNull(MyVar)    ' Returns False.'

'MyVar = Null
'MyCheck = IsNull(MyVar)    ' Returns True.

MyVar = Selection.Text

   If MyCheck = IsNull(MyVar) = True Then
   Selection.TypeText Text:="-"
   ElseIf MyCheck = IsNull(MyVar) = False Then

'    End If

'    If MyVar = Null Then
'    Selection.TypeText Text:="-"
'    ElseIf MyCheck = False Then
'    End If
End If
End Sub
Helmut Weber - 13 Feb 2005 22:33 GMT
Hi Gil,
for the first table that is touched by the selection:

Dim c As Cell
For Each c In Selection.Tables(1).Range.Cells
  If Len(c.Range.Text) = 2 Then
     c.Range.Text = "-"
  End If
Next

There may be faster ways, though,
but not many, probably.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Jezebel - 13 Feb 2005 22:36 GMT
Don't understand your code at all, but perhaps what's throwing you off is
that every cell -- including empty cells -- contains a minimum of two
characters: chr(13)chr(7).

Dim pCell as Word.Cell
pCell = Selection.Tables(1).Cell(1,1)
Do
   If len(pCell.Range) = 2 then
       pCell.Range = "-"
   end if
   set pCell = pCell.Next
Loop until pCell is nothing

> Hi All,
>
[quoted text clipped - 33 lines]
> End If
> End Sub
Gil Carter - 13 Feb 2005 22:43 GMT
Whoaah!
REALly fine, .... and SOOO fast.
Thans a Mil to you both!
:)
Gil
> Don't understand your code at all, but perhaps what's throwing you off is
> that every cell -- including empty cells -- contains a minimum of two
[quoted text clipped - 46 lines]
>> End If
>> End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.