![]() |
|
#1
|
|||
|
|||
|
Let's say I have a 3x4 table with this data:
I'd like to select the first three cells, and then quickly past them onto the table so that the table will look like this: And not like this: Can I do that without macros? Thank you very much! |
|
#2
|
||||
|
||||
|
It can't be done without macros. It can be done with a macro, based on your example. However there can be no split or merged cells and the selection must be contiguous.
Code:
Sub PasteContinuous()
'Graham Mayor - http://www.gmayor.com - Last updated - 25/11/2016
Dim oRng As Range, oRng1 As Range, oRng2 As Range
Dim Coll As New Collection
Dim oCell As Cell
Dim i As Long
If Selection.Information(wdWithInTable) Then
Set oRng = Selection.Range
For Each oCell In oRng.Cells
Set oRng1 = oCell.Range
oRng1.End = oRng1.End - 1
Coll.Add oRng1.Text
Next oCell
Set oCell = oRng.Next.Cells(1)
Do
On Error GoTo lbl_Exit
For i = 1 To Coll.Count
Set oRng2 = oCell.Range
oRng2.End = oRng2.End - 1
oRng2.Text = Coll(i)
Set oRng2 = oRng2.Cells(1).Range
Set oCell = oCell.Next
Next i
Loop
End If
lbl_Exit:
Set oCell = Nothing
Set oRng = Nothing
Set oRng1 = Nothing
Set oRng2 = Nothing
Set Coll = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Importing Data from Excel - Format of table messed up in Word Table
|
epsulliv | Word Tables | 6 | 08-24-2015 07:29 AM |
| Table of Contents - Wrap-around on long heading looks awful | Dr Wu | Word | 3 | 07-17-2013 10:25 AM |
Cells no longer wrap text when changed in nested table
|
erik2000 | Word Tables | 1 | 03-29-2013 03:27 PM |
Wrap text in table
|
andrei | Word Tables | 7 | 10-31-2011 05:37 AM |
| Pasting table in Photoshop cutting off table | azdolfan | Word Tables | 0 | 05-16-2010 01:52 PM |