Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-23-2014, 12:21 PM
gmaxey gmaxey is offline Copying text range of cells to different cells adds an extra line Windows 7 32bit Copying text range of cells to different cells adds an extra line Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

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 text range of cells to different cells adds an extra line Copying cells isminoh Excel 5 04-18-2012 11:49 AM
Copying text range of cells to different cells adds an extra line 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft