Solved

using a variable in a word table formula

Posted on 2010-08-22
2
270 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

943 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

16 Experts available now in Live!

Get 1:1 Help Now