Solved

using a variable in a word table formula

Posted on 2010-08-22
2
267 Views
Last Modified: 2012-06-21
I want to write a subroutine that puts variables into cells in a table. The subroutine below works perfectly for the job except that I haven't found a way to have a variable in the formula:

With Selection.Tables(1).Rows(row)
    .Cells(1).Range.Text = item
    .Cells(2).Range.Text = desc
    .Cells(3).Range.Text = qty
    .Cells(4).Range.Text = price
    .Cells(5).Formula "=c3*d3\#$,0"
End With

In this routine above the formula is hard coded to row 3. How can I modify that line to make it use the row variable used in the first line of the code snippet?
0
Comment
Question by:karimjohnson
2 Comments
 
LVL 4

Accepted Solution

by:
MeLindaJohnson earned 500 total points
ID: 33498081
With Selection.Tables(1).Rows(row)
    .Cells(1).Range.Text = item
    .Cells(2).Range.Text = desc
    .Cells(3).Range.Text = qty
    .Cells(4).Range.Text = price
    .Cells(5).Formula "=c" & row & "*d" & row & "\#$,0"
End With

0
 

Author Closing Comment

by:karimjohnson
ID: 33501434
Brilliant!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now