The information in this article applies to:
SUMMARYThe examples in the "More Information" section of this article demonstrate two ways you can find the address of the cell containing the largest or smallest value in a range of cells. If you are using a single row or column of data, you can use a worksheet formula. If you are using multiple rows or columns of adjacent data, you will need to create a custom Visual Basic for applications function. For examples of both methods, see the "More Information" section of this article. MORE INFORMATIONUsing FormulasYou can return the address of the cell with the largest or smallest value in a column or row by using the CELL(), OFFSET(), and MATCH() functions along with the MAX()or the MIN() function.If there are multiple occurrences of the largest or smallest value, the following formulas will return the cell address of the first occurrence of the value. If there is only one occurrence of the value, the address of the cell containing that value will be returned. To return the address of a cell in a column (in this example, column A, cells A1:A10), use the appropriate formula in the following table.
To return the address of a cell in a row (in this example, column A, cells
A1:J1), use the appropriate formula in the following table.
Using Custom FunctionsMicrosoft 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.aspTo return the cell address of the largest value in an adjacent range that is larger than a single column or row, you can create a custom Microsoft Visual Basic for Applications function.
To find the cell address of the smallest value in an adjacent range,
substitute the Min() function for the Max() function as in the following
example:
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: 8.00 adjacent contiguous nonadjacent noncontiguous discontiguous discontinuous maximum minimum greatest least
Keywords : kbprg kbdta PgmHowto xlformula KbVBA |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |