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  

Address Table Header Rows



 
 
Thread Tools Display Modes
  #1  
Old August 1st, 2006, 01:52 PM posted to microsoft.public.word.tables
Michael Koerner
external usenet poster
 
Posts: 2,341
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  
Old August 5th, 2006, 05:34 PM posted to microsoft.public.word.tables
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
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




 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Choosing a package, return all items Teri New Users 10 June 7th, 2006 03:34 PM
Query is not updatable - Doug Johnson via AccessMonster.com Running & Setting Up Queries 3 January 21st, 2006 01:36 AM
Need to Improve Code Copying/Pasting Between Workbooks David General Discussion 1 January 6th, 2006 04:56 AM
Multiple Options Group Patty Stoddard Using Forms 19 August 4th, 2005 02:30 PM
Improve the Address Book Bill Molony General Discussions 10 February 18th, 2005 12:49 AM


All times are GMT +1. The time now is 02:13 PM.


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