C
CodeDawg
Using Word 2000 on XP.
I would like to merge the top 4 rows of each column in a table that has 4+
rows.
Tried this:
Dim t1 as Table
Dim r1 as Range
For i = 1 To t1.Columns.Count
Set r1 = t1.Cell(1, i).Range
r1.End = t1.Cell(4, i).Range.End
r1.Cells.Merge
' r1.Select
' With Selection
' .Cells.Merge
' End With
Next i
It throws an error: Requested Member of the Collection does not exist.
Is r1 not returning a cells collection? This scheme works when I am merging
cells along a row.
If I comment out r1.Cells.Merge statement and uncomment
the selection commands, the code works. Why does that work?
I do not like using selection objects.
So I ended up with the following code that works (using cell objects with
Merge method):
Dim t1 as Table
Dim c1 as Column
For i = 1 To 3
For Each c1 In t1.Columns
c1.Cells(1).Merge MergeTo:=c1.Cells(2)
Next c1
Next
Anyone have any insight range issue?
Best regards and thank you.
I would like to merge the top 4 rows of each column in a table that has 4+
rows.
Tried this:
Dim t1 as Table
Dim r1 as Range
For i = 1 To t1.Columns.Count
Set r1 = t1.Cell(1, i).Range
r1.End = t1.Cell(4, i).Range.End
r1.Cells.Merge
' r1.Select
' With Selection
' .Cells.Merge
' End With
Next i
It throws an error: Requested Member of the Collection does not exist.
Is r1 not returning a cells collection? This scheme works when I am merging
cells along a row.
If I comment out r1.Cells.Merge statement and uncomment
the selection commands, the code works. Why does that work?
I do not like using selection objects.
So I ended up with the following code that works (using cell objects with
Merge method):
Dim t1 as Table
Dim c1 as Column
For i = 1 To 3
For Each c1 In t1.Columns
c1.Cells(1).Merge MergeTo:=c1.Cells(2)
Next c1
Next
Anyone have any insight range issue?
Best regards and thank you.