The information in this article applies to:
SUMMARYThe Fill feature always increments relative references by one for each cell filled. This article shows how to use Microsoft Visual Basic for Applications code to fill a range of cells with a formula and increment the relative references by an amount that you choose. 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.aspAs an example, suppose you have the following list of names and addresses on a Microsoft Excel worksheet: A1: Alice Suppose you want the range B1:B5 to contain links to the names in this list, but not to the addresses. If you enter "=A1" in cell B1, select the range B1:B5, and click Fill Down on the Edit menu, you will get the following formulas: B1: =A1rather than the following formulas: B1: =A1which, in this example, would produce the desired result. The following sample macro enables you to get this result without having to type the formulas in each cell. To use the sample macro, first select a vertical range of cells starting with the cell that contains the formula you want to fill down. In the example above, you would select the range B1:B5. When you run the macro, a dialog box will prompt you for the number of cells to increment the relative references for each cell filled.
Sample Visual Basic Procedure
REFERENCESFor additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base: Q163435 VBA: Programming Resources for Visual Basic for Applications Additional query words: 5.00a 5.00c 8.00
Keywords : kbprg kbdta kbdtacode PgmHowto KbVBA |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |