Can I use VBA to add cells (over blanks) then do multiplication

I have a Word table in which the last column contains numbers (3 and 4) and 
some bank cells and I want it add them and put the total into the second last 
row (7 in this case). The last row contains a multiplier (3) which when 
applied to the total results in 21. Below is the table.
|   |   | 3 |
|   |   |    |
|   |   | 4 |
|   |   | 7 |
|   | 3 |21|
How can I achieve this in VBA (under Word 2003 and 2007) remembering that 
the user can add rows to the table and the last column can contain blank 
cells.

Thanks in advance for any assistance,

Peter Evans

0
Utf
12/27/2009 2:36:01 PM
word.vba.general 1023 articles. 1 followers. Follow

1 Replies
843 Views

Similar Articles

[PageSpeed] 37

Sub ScratchMaco()
Dim oTbl As Word.Table
Set oTbl = Selection.Tables(1)
oTbl.Cell(oTbl.Rows.Count, oTbl.Columns.Count).Range.Text = 3 * 
fcnTallySubTotal(oTbl)
End Sub
Function fcnTallySubTotal(ByRef Table As Word.Table) As Double
Dim i As Long
For i = 1 To Table.Rows.Count - 2
  On Error Resume Next
  fcnTallySubTotal = fcnTallySubTotal + CDbl(Left(Table.Cell(i, 
Table.Columns.Count).Range.Text, Len(Table.Cell(i, 
Table.Columns.Count).Range.Text) - 2))
  On Error GoTo 0
Next i
End Function


Peter wrote:
> I have a Word table in which the last column contains numbers (3 and
> 4) and some bank cells and I want it add them and put the total into
> the second last row (7 in this case). The last row contains a
> multiplier (3) which when applied to the total results in 21. Below
> is the table.
>>   |   | 3 |
>>   |   |    |
>>   |   | 4 |
>>   |   | 7 |
>>   | 3 |21|
> How can I achieve this in VBA (under Word 2003 and 2007) remembering
> that the user can add rows to the table and the last column can
> contain blank cells.
>
> Thanks in advance for any assistance,
>
> Peter Evans 


0
Greg
12/27/2009 2:59:44 PM
Reply:

Similar Artilces:

Recieving email with nothing in them? Blank??
From time to time, I will recieve email from friends, family, or business...and when I get the email, I open it up to find nothing but white space. I can't find a common thing between emails. I just know it is very frustrating when I have to ask people to resend the email to me or to a new address. When I look at my mail on the server, it is fine. It is when I open Outlook and it downloads it to my desktop. I get nothing. Any ideas? Cheers.. vg Sorry, wanted to add that I am using OL2003 with WINXP and everything is updated SP wise. I am starting to see some articles on this...

Changing Cells and entering data in them
Thanks for the help again. Big thanks to Steve you've got me this far. I went out and bought a book, but it's like reading a foreign language. I was informed today that I can't have message boxes come up. I need to have the code point at the cells and if they are blank turn which ever one is blank red or if both are then both turn red then pause for each cell to be filled in. Cell F14 "Last Name" then automatically go to Cell F16 "First Name" on tab or enter. Basically if Cell F22 or F23 has an X in it, Cells F14 an F16 turn red and cell F14 has the focus...

Using Relative path for XML data file?
Is there a way to specify a relative path to an XML data file imported into Excel 2003? I am writing a web app that generates report data as XML for the user to download to their local machine. This data is to be consumed by an Excel reporting spreadsheet, which contains display-formatted tables and charts that are mapped to various data fields in an XML Map, which is in turn linked to the xml data file they will download. The idea is the user only needs to download the data for updates, not the whole spreadsheet. However, since I cannot predict the path where the user will store their...

Formula without using numbers after decimal in the answer
I have a formula that derives the answer from a figure with a decimal. I don't want to use the figures after the decimal. Is there a way to just use the whole number and omit the numbers after the decimal without having to manually key in all these numbers manually? Thanks, Mustang You can use the INT function. This 'rounds down' any number to th nearest integer, e.g. if A1=2.567, a formula in B2 of =INT(A1) return 2 HTH Bruc -- swatsp0 ----------------------------------------------------------------------- swatsp0p's Profile: http://www.excelforum.com/member.php?...

Is anyone an expert with outlook that I can call on the phone?
How do I share calenders between outlook and my MSN Premier account? Assuming you are using the outlook connector, you need to set the msn account to be the default message store then outlook will use the msn calendar as the default. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com Outlook Tips by email: mailto:dailytips-subscribe-request@lists.outlooktips.net EMO - a weekly newsletter about Outlook and Exchange: mailto:EMO-NEWSLETTER-SUBSCRIBE-REQUEST@PEACH.EASE.LSOFT.COM You can access this...

Disable Secure Sockets Layer on exchange server when using RPC over HTTP
Hi im trying to enable RPC over HTTP to enable users to establish contact to my Excahger server 2003 over the internet. Now, I dont want to use SSL (security not that important) and i am told by this article that i can disable SSL in windows registry. Quote: Note While RPC over HTTP does not require Secure Sockets Layer, you must modify the registry to enable RPC over HTTP if you do not want to use Secure Sockets Layer. Microsoft recommends that you enable and require Secure Sockets Layer for your RPC over HTTP communications. At this address: http://support.microsoft.com/?id=833401 But i ...

default values in a cell
Hello, can you help me please Cell B1 contains a complex mathematical formula which requires (in several places) a number from cell A1. Cell A1 can contain any integer number, but it is usually the same (30). I would like to be able to leave cell A1 empty, and only enter a number when it is not 30 , ie the default value of A1 is 30, unless specified. How do I go about this ? Should I look at conditional formatting, or put lots of IF functions into an already complex formula? Thank as always KK Use 2 cells Modify the complex formula to use B1 rather than A1 ( or any other un-u...

print multiple pages on one sheet of paper
I am using mailmerge in Publisher to create placecards for a party we are hosting. The final size of the placecards is 1.5" by 1.5" and we have to print 100 final cards. Publisher gives me the option of printing multiple copies of the same page on one sheet of letter sized paper or one page on one sheet of letter sized paper. What I would like to do, however, is print multiple different pages on one sheet of paper. If I cannot find a solution for this, I will need to print 100 separate pages with a 1.5" square box of copy in the center of each sheet. In page setup, sel...

Show date, time & day of week in one cell
Can I show the date, time and day of week in one cell. I have: 09/03/07 8:30 AM in one cell using the format (Format/Cells/Custom): [$-409]mm/dd/yy h:mm AM/PM;@ Excel refuses to accept ddd for Mon or dddd Monday at the end of the format I want it to read: 09/03/07 8:30 AM Monday in 1 cell. I have Excel 2003. One way: mm/dd/yy h:mm AM/PM dddd;@ In article <Xns99B8A3CAF9130pencilunlistedcom@208.49.82.220>, Burp <burp@beep.comINVALID> wrote: > Can I show the date, time and day of week in one cell. > > I have: > 09/03/07 8:30 AM > in one cell using the for...

using the journal on outlook
Once I link an email to the journal, can I still find that email in my mail box? I seem to be able to get to it only via the journal. If this is the way it is supposed to be, how do I remove it from the journal and get it back into my mail box? Am I just missing something? -- thanks, Independent Are you linking to the item or putting a copy into the journal item? Also, has the item been archived or not? "Independent" <Independent@discussions.microsoft.com> wrote in message news:868279F2-53C8-403A-97F5-604CEECD873C@microsoft.com... > Once I link an email to the journ...

how do I add error bars to a 3D chart in excel?
The help states you can only add error bars to data series in 2D area. Is there a way to add them to a 3D chart? Hi, I would not have thought so. Obviously as it is not a built-in option the only way would be a work around perhaps using dummy series. Unfortunately you can create 3d combination charts. Stick with the 2d view. Cheers Andy elahe wrote: > The help states you can only add error bars to data series in 2D area. Is > there a way to add them to a 3D chart? -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info I checked, and error bars are not offered for 3D ch...

Excel VBA
When you select the autofilter, the drop down list is created from the unique data in that column. Is there any way to customize this list, so the changes are permanent? For instance, I might have in one(1) column the following 4 row entries: red, blue, green (all are single cell entries) red, blue red blue, green I want my autofilter drop down list to read: red instead of red, blue, green blue red, blue green red blue, green (like normal) If I chose red from the drop down list...

Call & Place Graphic Based on Cell Value?
Is there any way to call & place a graphic image based upon a cell value? Maybe you can look at J.E. McGimpsey's page: http://www.mcgimpsey.com/excel/lookuppics.html documike wrote: > > Is there any way to call & place a graphic image based upon a cell value? -- Dave Peterson ...

Can I share entities in migration process?
The entities in CRM have only one owning user. If I want=20 who a user see a entity of another user, the entity must=20 be shared with this user.=20 Well, I want migrate entities who must be shared with some=20 users. Exists a way to do it? Thank you for pay attention and sorry my bad english. []'s Vin=EDcius Pitta Lima de Ara=FAjo ...

Let me use the Line Color icon on charts
It would speed up a lot of my work if I could use the Line Color icon on Excel charts, the same way I am able to use the Fill Color and Font Color icons. However, when I highlight any chart object, like the Plot Area, Chart Area, or a Series, the Line Color icon is disabled. -- Stuart Bratesman, Jr., MPP Muskie School of Public Service Univ. of Southern Maine Portland, Maine ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If ...

Can't do adjustment in analytical accounting
I am trying to change an analytical assignmnet through the Edit Analysis. When I try and change it, I receive an error stating "The Code of this Transaction Dimension cannot be adjusted". Has anyone seen this before? I have done similar changes many times, but I don't know why I can't now. Any insight would be helpful. Thanks, KJ Hi KJ What version of Gp are you running? I haveseen this happen in 8 but one of the service packs fixed it. (I think it was SP 4 or 5) Fliehigh "KJ" wrote: > I am trying to change an analytical assignmnet through the Edit >...

Does Outlook use the DAV protocol?
I'm an Outlook Express user who wants to switch to Outlook. I received a notice from Microsoft that includes the following: "... as of June 30, 2008, Microsoft is disabling the DAV protocol and you will no longer be able to access your Hotmail Inbox via Outlook Express." Please tell me if this action by Microsoft will affect Outlook in the same manner, or am I free to make the switch. "BudV" <BudVitoff@(NO)att.(SPAM)net> wrote in message news:%230XUDi%23zIHA.2384@TK2MSFTNGP02.phx.gbl... > I'm an Outlook Express user who wants to switch to Outlook...

formula or VBA
I need to search through a column checking condtions. If the conditions are met, then I want to enter the corresponding value in the column next to it into a different cell. Basically, I want to search column A and, if the conditions are met, put the value in B into C. Would this be easier via formula or code? And maybe some starting suggestions would be nice if you don't mind. -- Thanks, Jim in a formula in col b =if(cond,a1,"") using vba for each c in range("a1:a100") if cond then c.offset(0,1)=c next -- Don Guillett SalesAid Software donaldb@281.com "...

GPS 8 service pack 2 and add new company
After installing service pack 2 for GP 8, I am not able to add or log on to the new company. Error during upgrade is “Entries haven't made to all required fields. Would you like to show the required fields on all windows in greatplains” When I try to log on to GP getting another error “file for this company have not been updated” Please help Rajesh ...

How can I change text to proper text in multiple cells.
I need to change names that are all in caps to proper case in 100 cells. If I click each one individually, it works, but I need to be able to perfomr this funcion automatically on all the cells. One other post said to be sure calc is set to automatic and mine is. Any instruction is most appreciated. Thank you. Insert a helper column to the right of the column with the names. Then use a formula like: =proper(a1) and drag down that column Then select that column edit|copy select the original range Edit|paste special|Values And then delete the helper column. bethye99 wrote: > > I...

can't open new worksheets in a separate window
I've been trying to open multiple wookbooks in Excel, but they won't open in a new window. Instead they continue to open in the same window - one on top of the other. I've tried playing around with the maximize and restore, but to no avail. I tried right clicking on the Excel button in the taskbar to cascade the windows, but the pop-up menu is inactive. any advice would be greatly appreciated. Running Excel 2003, Windows XP. This might be it: Tools - Options - View tab - Show: Windows in taskbar. Earl Kiosterud www.smokeylake.com "3R's" <3R's@di...

Can validation lists be enlarged
When a validtion list is created can this be enlarged in a spreadsheet which has been reduced to view. Hi for a workaround see: http://www.contextures.com/xlDataVal08.html#Larger -- Regards Frank Kabel Frankfurt, Germany "AC" <AC@discussions.microsoft.com> schrieb im Newsbeitrag news:B6A557E7-7B2C-459B-94CE-02606B6CAB3A@microsoft.com... > When a validtion list is created can this be enlarged in a spreadsheet which > has been reduced to view. ...

Remote humans can't get email addressed to them from within the do
I call them remote humans because they are not "users" set up on the SBS2003 system. I've set up a local domain, call it domain.local, and the email domain is domain.org. For all internal users, there is no problem. But there are two people, out of state, with email addresses user1@domain.org and user2@domain.org. Our email is hosted, and we use the POP3 connector to bring it into our Exchange server. We do not use POP3 connector for the remote humans - their Outlook client has the POP3 account set up on it. These remotes will never connect to the local domain, all th...

How do I lock individuals cells within an Excel spreadsheet so th.
i am trying to lock cells that have formulas in them, but other cells in the spreadsheet need to be unlocked so the end users can enter information. Hi first select the cells for which you want to allow entries and goto 'Format - Cells - Protection' and uncheck 'Locked'. Now protect the sheet 'Tools - Protection' "ucastores" wrote: > i am trying to lock cells that have formulas in them, but other cells in the > spreadsheet need to be unlocked so the end users can enter information. ...

How can I create Schedule Chart?
I have simply an activity list which shows START and FINISH date of related activity. I need to put this information into a Chart, so that i will get a bar chart highligting the line between the START and FINISH date of the activity. It is very similar to what we can create in Microsoft Project. Do you know a specific chart type for this? It's called a Gantt chart: http://office.microsoft.com/en-us/excel/HA010346051033.aspx http://peltiertech.com/Excel/Charts/GanttLinks.html http://www.mrexcel.com/tip058.shtml -- David Biddulph "mezzanine1974" <savas_karaduman@yahoo.com>...