Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 10-12-2014, 10:55 AM
gmaxey gmaxey is offline Using data retreived from a loop in a calculation Windows 7 32bit Using data retreived from a loop in a calculation 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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help with age calculation!!! Microsoft Idiot Word 4 10-29-2012 05:54 AM
Using data retreived from a loop in a calculation Formula calculation danbl Excel 8 02-23-2012 04:35 AM
Using data retreived from a loop in a calculation Calculation within Cells manich1 Excel 2 12-07-2011 02:59 PM
Using data retreived from a loop in a calculation Macro to loop in subfolders, change links, export xml data Catalin.B Excel Programming 2 09-08-2011 11:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:34 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