The information in this article applies to:
SUMMARYIn Microsoft Excel, you can use a Microsoft Visual Basic for Applications macro to sum or subtract two ranges of data and to then place the result into a third range without using formulas in the cells. You can do this in the same workbook or from more than one workbook into a workbook using defined names. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspThere are several ways to perform the task of adding or subtracting columns of data together. You can use a For Each...Next loop in the same workbook to subtract values in one column from another column and have the results appear in a third column. For an example of how to do this using Visual Basic code, perform the following steps in Microsoft Excel:
You can use the same code to add the columns. To do this, just change the minus sign to a plus sign in the CurCell.Value line, as follows:
To add or subtract from different workbooks using Visual Basic code, use
the following steps:
Additional query words: 97 8.00 XL97 XL98 XL7 XL5
Keywords : kbprg kbdta kbdtacode PgmHowto KbVBA |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |