Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Searching for a Value Using a Function.

Searching for a Value Using a Function

Written by Allen Wyatt (last updated February 4, 2026)

4

Thor wonders if there is a way to perform a lookup without having to specify a column or row and having the result be the address of the cell at which the value is found. For instance, he wants to look up a value (such as 345 or "my text") and have the function search all the cells in all the worksheets in the workbook and return the full address of the cell in which the value was found.

The approach you use will be dictated by the range you want to search. If you want to search on the same worksheet on which you want the answer displayed, then you can use a formula, such as the following:

=ADDRESS(MAX(ROW(1:5)*(A1:E5="my text")),
MAX(COLUMN(A1:E1)*(A1:E5="my text")),4)

This should be entered as an array formula (press Ctrl+Shift+Enter) if you are not using Excel 2019, Excel 2021, or the version of Excel provided with Microsoft 365. (If you are using one of those versions, then just enter the formula normally.) It only searches in the range A1:E5. You can, if desired, change the range by adjusting the formula appropriately.

A larger search area would be to look at an entire worksheet. This can still be done using a formula, such as the following:

=ADDRESS(MAX(ROW(Sheet1!1:1048576)*(IF(Sheet1!1:1048576=$A$1,1,0))),
MAX(COLUMN(Sheet1!$1:$1048576)*IF(Sheet1!1:1048576=$A$1,1,0)))

The formula assumes that what you are looking for is stored in cell A1. You should change the Sheet1 designation to the name of whatever worksheet you want searched. Again, if you are using Excel 2019, Excel 2021, or the version of Excel with Microsoft 365, you can enter this as a regular formula. If you are using an older version of Excel, you should enter it as an array formula by pressing Ctrl+Shift+Enter.

If you want to search a wider range, such as all the worksheets in a workbook, then the best solution is to use a macro that calls upon the Find function within Excel.

Function FindAddr(vValue As Variant)
    Dim wks As Worksheet
    Dim rCell As Range
    Dim bFound As Boolean

    bFound = False
    For Each wks In ActiveWorkbook.Worksheets
        With wks
            Set rCell = .Cells.Find _
              (What:=vValue, After:=.Cells(1), _
              LookIn:=xlValues, LookAt:=xlWhole, _
              SearchOrder:=xlByRows, _
              SearchDirection:=xlNext, _
              MatchCase:=False)
            If Not rCell Is Nothing Then
                bFound = True
                Exit For
            End If
        End With
    Next
    If bFound Then
        FindAddr = wks.Name & "!" & _
          rCell.Address(False, False)
    Else
        FindAddr = "Not Found"
    End If
    Set wks = Nothing
    Set rCell = Nothing
End Function

This function is designed to be called from another macro, which passes it whatever should be searched for in the vValue parameter. The function returns either the full address (including worksheet name) of the first match, or it returns "Not Found" if there was no match.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11524) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Searching for a Value Using a Function.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Sorting Text

Word makes it easy to sort the information that is contained in your document. Here's how to accomplish this.

Discover More

Editing the Same Cell in Multiple Sheets

When creating a workbook, you may need to make changes on one worksheet and have those edits appear on the same cells in ...

Discover More

Determining If a Cell is Bold

Want to figure out if the text in a cell is bold? The best approach is to use your own user-defined function, as ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!

More ExcelTips (ribbon)

Identifying Digit-Only Part Numbers Excluding Special Characters

When working with data in Excel, you often need to determine if that data meets criteria that you specify. This tip ...

Discover More

Solving a Quadratic Equation

One of the staples of high school algebra classes is the quadratic equation. If you need to solve such equations in ...

Discover More

Creating a Static Cell Reference

When you edit a worksheet, adding and deleting rows and columns, Excel automatically updates references to cells ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four more than 7?

2022-10-01 12:46:58

J. Woolley

Sorry, but I rearranged parameters for the ListMatchingCells function described in my previous comments below. Here is the new syntax:n=ListMatchingCells(Value,[LookIn],[MatchCase],[MatchEntire],[AllSheets])nValue can be a numeric or text constant or a formula's result or a cell (like A1) with a non-blank value; * and ? are wild card characters and ~ is the escape character, the same as Find (Ctrl+F). nThe first character of LookIn (case ignored) must be V for Values (default), F for Formulas, N for Notes (legacy unthreaded comments), C for Comments (threaded), or A for All (V, F, N, and C).nIf MatchCase is FALSE (default), alphabetic case will be ignored when Value is text; if TRUE, the case of a text Value must match.nIf MatchEntire is FALSE (default), a partial match is accepted; if TRUE, the entire content must match.nIf AllSheets is FALSE (default), only the current worksheet will be evaluated; if TRUE, all worksheets in the workbook will be included.nSee https://sites.google.com/view/MyExcelToolbox/


2022-09-30 12:08:35

J. Woolley

Two optional parameters have been added to the ListMatchingCells function described in my previous comment below. Here is the new syntax:n=ListMatchingCells(Value,[MatchCase],[AllSheets],[LookIn],[LookAt])nThe first character of LookIn must be V for Values (default), F for Formulas, N for Notes (legacy unthreaded comments), C for Comments (threaded), or A for All (V, F, N, and C).nThe first character of LookAt must be P for Partial (default) or W for Whole (match entire cell).nAlphabetic case of LookIn and LookAt is ignored.nSee https://sites.google.com/view/MyExcelToolbox/


2022-08-05 14:46:37

J. Woolley

My Excel Toolbox includes the following dynamic array function to return a list of cells matching Value:n=ListMatchingCells(Value,[MatchCase],[AllSheets])nValue can be a numeric or text constant or a formula's result or a cell (like A1) with a non-blank value.nIf MatchCase is FALSE (default), alphabetic case will be ignored when Value is text; if TRUE, the case of a text Value must match.nIf AllSheets is FALSE (default), only the current worksheet will be evaluated; if TRUE, all worksheets in the workbook will be included.nExcel 365 or 2021+ is required when this function is used in a cell formula; it must NOT be used with My Excel Toolbox's SpillArray function (directly or indirectly). In older versions of Excel, it can be called by a macro (Sub) with results in a MsgBox or posted to a worksheet.nHere is a simplified version:nnFunction ListMatchingCells(Value, Optional MatchCase)n    Dim C As Collection, rCell As Range, n As Longn    Dim sAddr As String, sFirst As String, sSheet As Stringn    Application.Volatilen    If Value = vbNullString Thenn        ListMatchingCells = CVErr(xlErrValue)n        Exit Functionn    End Ifn    Set C = New Collectionn    C.Add "Cells matching '" & Value & "'"n    With Application.Caller.Worksheet.UsedRangen        Set rCell = .Cells((.Rows.Count - .Row + 1), _n            (.Columns.Count - .Column + 1)) ' last celln        Set rCell = .Find(What:=Value, After:=rCell, _n            LookIn:=xlValues, LookAt:=xlWhole, _n            SearchOrder:=xlByColumns, _n            SearchDirection:=xlNext, _n            MatchCase:=MatchCase)n        If Not (rCell Is Nothing) Thenn            sAddr = rCell.Addressn            sFirst = sAddrn            sSheet = "'" & rCell.Parent.Name & "'!"n            Don                C.Add sSheet & sAddrn                ' Range.FindNext does NOT work in a UDFn                Set rCell = .Find(What:=Value, After:=rCell)n                sAddr = rCell.Addressn            Loop Until sAddr = sFirstn        End Ifn    End Withn    If C.Count = 1 Then C.Add "None"n    ReDim A(1 To C.Count, 1 To 1) As Variantn    For n = 1 To C.Countn        A(n, 1) = C(n)n    Next nn    Set C = Nothingn    ListMatchingCells = AnEnd FunctionnnSee https://sites.google.com/view/MyExcelToolbox/


2022-07-09 10:42:25

J. Woolley

The Tip's FindAddr user-defined function (UDF) can also be used in a cell formula. For example:n=FindAddr(345)n=FindAddr("my text")n=FindAddr($A$1)n=$A$1&" @ "&FindAddr($A$1)nIt searches cells in each worksheet 1 to Worksheets.Count, columns left-to-right, rows top-to-bottom, and returns only the first cell with a value that wholly matches the searched value ignoring alphabetic case and cell format. For each worksheet, cell $A$1 is searched last.nThe UDF could be modified to return all matching cells as an array.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.