Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-13-2018, 08:29 AM
nbooth1983 nbooth1983 is offline Using Excel tables and formula in a word document Windows 10 Using Excel tables and formula in a word document Office 2016
Novice
Using Excel tables and formula in a word document
 
Join Date: Apr 2018
Posts: 1
nbooth1983 is on a distinguished road
Default Using Excel tables and formula in a word document

I work in a vets and have a client handout with information about pet food which is a word document. We use these handouts to inform clients of how much different sizes bags of dog food will cost them.We have been calculating this by hand and writing the information on a printed sheet previously, but I now want to do this digitally.



I have created a "cost calculator" in excel which will calculate the cost per day of dog food based on the daily feeding allowance. The idea I have is to input the daily feeding amount (which will be different for each dog) and the formula will do the rest. This works fine in the excel sheet I have created.

What I wanted to know is if there is a way to input this formula into word, or to input the text info into excel but format it like a word document as I want to add logos and other images.

I have attached sample documents which will hopefully make it a bit clearer as to what I want than my garbled post! Thanks in advance for any help.
Attached Files
File Type: xlsx Cost Calculator.xlsx (14.9 KB, 8 views)
File Type: docx Diet Sample Sheet.docx (20.3 KB, 8 views)
Reply With Quote
  #2  
Old 04-13-2018, 09:16 PM
Guessed's Avatar
Guessed Guessed is offline Using Excel tables and formula in a word document Windows 10 Using Excel tables and formula in a word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The attached example shows how you can do it in Word without Excel. It uses content controls and allows you to change the daily allowance or cost per bag and the other values recalculate with a macro as you leave the content control.
The code included in the file looks like this
Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
  Dim iAmt As Long, iPrice12 As Long, iPrice4 As Long, iDays12 As Long, iDays4 As Long
  Dim iDailyCost12 As Long, iDailyCost4 As Long
  Select Case aCC.Title
    Case "Daily Amount", "BagCost12", "BagCost4"
      iAmt = ActiveDocument.SelectContentControlsByTitle("Daily Amount").Item(1).Range.Text
      iPrice12 = ActiveDocument.SelectContentControlsByTitle("BagCost12").Item(1).Range.Text
      iPrice4 = ActiveDocument.SelectContentControlsByTitle("BagCost4").Item(1).Range.Text
      iDays12 = 12 * 1000 / iAmt
      ActiveDocument.SelectContentControlsByTitle("Days12")(1).Range.Text = Format(iDays12, "#,###")
      iDays4 = 4 * 1000 / iAmt
      ActiveDocument.SelectContentControlsByTitle("Days4")(1).Range.Text = Format(iDays4, "#,###")
      iDailyCost12 = 100 * iPrice12 / iDays12
      iDailyCost4 = 100 * iPrice4 / iDays4
      ActiveDocument.SelectContentControlsByTitle("Daily12")(1).Range.Text = Format(iDailyCost12, "#,###")
      ActiveDocument.SelectContentControlsByTitle("Daily4")(1).Range.Text = Format(iDailyCost4, "#,###")
  End Select
End Sub
Attached Files
File Type: docm Diet Sample Sheet.docm (35.0 KB, 7 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Revise tables in a word document based on a reference table in excel modiria50989 Word VBA 1 08-29-2017 03:07 PM
Adding tables to Created word document whilst other word document open Help rpb925 Word VBA 18 03-30-2016 04:45 PM
Include Excel Tables in Book Document SQLUSA Word 20 07-16-2012 03:59 AM
Using Excel tables and formula in a word document Copying Multiple tables from excel into a single word document dineshtgs Word Tables 1 04-07-2011 01:27 AM
Linking Excel Pivot Tables in a Word Document wmarsh3561 Word Tables 0 11-17-2009 06:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:18 PM.


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