Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Michael Koerner Michael Koerner is offline
external usenet poster
 
Posts: 41
Default Address Table Header Rows

I have a number of tables that are created from merging Excel data I am
looking for a way to go through the document and when ever the first column
last name changes from A to B and B to C I would like to insert a new row,
merging all the cells with the new Alpha character centered, Bolded, and the
cell bordered on the outside. Any suggestions greatly appreciated.


---
Regards
Michael Koerner


  #2   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Address Table Header Rows

The following macro should do what you want as long as the Lastname is the
first word in the cells of the first column.

Dim i As Long
Dim mytable As Table
Dim lname As Range
Dim Initial As String
Dim Alpha As String
Dim newrow As Row
Set mytable = ActiveDocument.Tables(1)
Alpha = " "
With mytable
For i = 1 To .Rows.Count
Set lname = .Cell(i, 1).Range
Initial = Left(lname.Text, 1)
If Initial Alpha Then
Alpha = Initial
Set newrow = mytable.Rows.Add(BeforeRow:=mytable.Rows(i))
newrow.Cells.Merge
newrow.Range.Text = Alpha
newrow.Range.Paragraphs(1).Alignment = wdAlignParagraphCenter
newrow.Range.Font.Bold = True
i = i + 1
End If
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Michael Koerner" wrote in message
...
I have a number of tables that are created from merging Excel data I am
looking for a way to go through the document and when ever the first column
last name changes from A to B and B to C I would like to insert a new row,
merging all the cells with the new Alpha character centered, Bolded, and
the cell bordered on the outside. Any suggestions greatly appreciated.


---
Regards
Michael Koerner




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem pasting landscape table rows [email protected] Page Layout 4 June 30th 06 11:01 AM
Headers and Footers in Main Body with Table Breaks NewUser_Sanket Page Layout 11 March 13th 06 09:18 PM
Protected table header jsmith Tables 2 September 29th 05 08:44 PM
Preventing deletion of header Jag Man Microsoft Word Help 10 August 11th 05 09:14 PM
Remove Rows from a Table after merging Kevin L Mailmerge 1 December 9th 04 11:13 AM


All times are GMT +1. The time now is 04:36 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"