View Single Post
 
Old 10-12-2014, 10:55 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I don't understand your question. The values are already contained in cells 2, 3, 4 and 5:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Word.Table
Dim dblOne As Double, dblTwo As Double
  Set oTbl = ActiveDocument.Tables(1)
  dblOne = CDbl(fcnGetCellText(oTbl.Cell(2, 1))) + CDbl(fcnGetCellText(oTbl.Cell(3, 1)))
  dblTwo = CDbl(fcnGetCellText(oTbl.Cell(4, 1))) + CDbl(fcnGetCellText(oTbl.Cell(5, 1)))
  ActiveDocument.Tables(2).Cell(1, 1).Range.Text = dblOne + dblTwo
  'or
   ActiveDocument.Tables(2).Cell(2, 1).Range.Text = (CDbl(fcnGetCellText(oTbl.Cell(2, 1))) _
      + CDbl(fcnGetCellText(oTbl.Cell(3, 1))) _
      + (CDbl(fcnGetCellText(oTbl.Cell(4, 1))) _
      + CDbl(fcnGetCellText(oTbl.Cell(5, 1)))))
End Sub
Function fcnGetCellText(oCell) As String
  fcnGetCellText = Left(oCell.Range.Text, Len(oCell.Range.Text) - 2)
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote