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.

Merge specific cells in a table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vicenflor - 26 Feb 2005 10:45 GMT
I have inserted a table with 5 rows en 17 columns using a macro. Now I want
to merge certain cells, for example : I n row1, I want to merge cells 1 to 5.
And in row 2, I want to merge cells 2 to cell 5. and further. I know in
advance which cells from a particular row need to be merged.

Is there some VBA code for this?

Thanks for the contribution
Doug Robbins - 26 Feb 2005 12:30 GMT
The following adds such a table at the location of the selection and then
merges those cells:

Dim mytable As Table, myrange As Range
Set mytable = ActiveDocument.Tables.Add(Range:=Selection.Range, NumRows:=17,
NumColumns:=5)
Set myrange = mytable.Cell(1, 1).Range
myrange.End = mytable.Cell(1, 5).Range.End
myrange.Cells.Merge
Set myrange = mytable.Cell(2, 2).Range
myrange.End = mytable.Cell(2, 5).Range.End
myrange.Cells.Merge

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

>I have inserted a table with 5 rows en 17 columns using a macro. Now I want
> to merge certain cells, for example : I n row1, I want to merge cells 1 to
[quoted text clipped - 5 lines]
>
> Thanks for the contribution
vicenflor - 26 Feb 2005 22:11 GMT
Thanks Doug,
The code runs fine!

> The following adds such a table at the location of the selection and then
> merges those cells:
[quoted text clipped - 18 lines]
> >
> > Thanks for the contribution

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.