![]() |
|
#1
|
||||
|
||||
|
Hey Fellas, I've got a macro that moves the text from one cell to another. The code goes something like this: Code:
Dim oRow as Row set oRow = ActiveDocument.Tables(2).Rows.Add oRow.Cells(1).Range.Text = ActiveDocument.Tables(1).Rows(1).Range.Cells(1).Text |
|
#2
|
|||
|
|||
|
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRow As Row
Set oRow = ActiveDocument.Tables(2).Rows.Add
'You need to strip the end of cell marker. This is a little cumbersome inline:
oRow.Cells(1).Range.Text = Left(ActiveDocument.Tables(1).Rows(1).Range.Cells(1).Range.Text, _
Len(ActiveDocument.Tables(1).Rows(1).Range.Cells(1).Range.Text) - 2)
'So use a function instead
oRow.Cells(1).Range.Text = CellContent(ActiveDocument.Tables(1).Rows(1).Range.Cells(1))
End Sub
Function CellContent(oCell As Cell) As String
Dim oRng As Word.Range
Set oRng = oCell.Range
oRng.End = oRng.End - 1
CellContent = oRng.Text
End Function
|
|
#3
|
||||
|
||||
|
Thanks Greg, I'll try this out tomorrow.
|
|
| Tags |
| cells, copying, tables |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Color-fill a range of cells, based on text in a different sheet. Possible? | unittwentyfive | Excel | 2 | 06-01-2014 06:48 AM |
| Copying a formula that uses pivottable cells | Paul46 | Excel | 0 | 02-08-2014 07:04 AM |
Copying cells
|
isminoh | Excel | 5 | 04-18-2012 11:49 AM |
Set range for merged Word table cells?
|
tinfanide | Word VBA | 1 | 02-06-2012 05:57 AM |
| Count range cells eliminating merge cells | danbenedek | Excel | 0 | 06-15-2010 12:40 AM |