The information in this article applies to:
SUMMARYWhen you write a Microsoft Visual Basic for Applications macro, you may need to loop through a list of data on a worksheet. There are several methods for performing this task. The "More Information" section of this article contains information about methods you can use to search the following types of lists:
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 a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/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.aspThe following code samples assume that the list has a header row starting in cell A1 and data starting in A2. To Search a List with a Constant, Known Number of RowsThis code moves down column A to the end of the list:
To Search a Dynamic List or a List with an Unknown Number of RowsThis code moves down through column A to the end of the list. (This code assumes that each cell in column A contains an entry until the end.) NOTE: If there are empty cells in column A throughout the data, then
you can modify this code to account for this condition, as long as
empty cells are a consistent distance apart. For example, if every
other cell in column A is empty (this might occur if every 'record'
uses two rows, with the second row indented one cell, for example), this
loop can be modified as follows:
To Search a List for a Specific Record
Additional query words: XL98
Keywords : kbdta kbdtacode xlvbainfo |
Last Reviewed: September 17, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |