VBA Find Function in Excel

Last Updated : 24 Mar, 2026

The VBA Find function searches for a specific value within a range of cells in Excel and returns the first matching cell as a Range object. Unlike Excel’s Ctrl+F, VBA Find enables automation, allowing you to programmatically locate and manipulate data based on criteria like value, case, or search direction.

Syntax of VBA Find Function

Below is the syntax given for using the find function in VBA,

RangeObject.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat) As Range

Parameters:

ParameterRequiredDescription
WhatRequiredThe value to search for (e.g., text, number).
AfterOptionalThe cell after which to start searching (e.g., Range("A3")).
LookInOptionalWhere to search: xlValues (cell values), xlFormulas (formulas), xlComments (comments).
LookAtOptionalMatch type: xlWhole (entire cell content) or xlPart (part of cell content).
SearchOrderOptionalSearch by: xlByRows (row-wise) or xlByColumns (column-wise).
SearchDirectionOptionalDirection: xlNext (forward) or xlPrevious (backward).
MatchCaseOptionalCase-sensitive search: True or False (default).
MatchByteOptionalFor double-byte languages (e.g., Japanese): True (match double-byte only), False (match single-byte).
SearchFormatOptionalCustom format to match (e.g., bold text; requires Application.FindFormat).

Steps to Use the VBA Find Function in Excel

Below are some Examples of VBA Find Function:

How to Use the Find Function without Parameter

Let's take a sample of data. Below is the dataset given:

Sample-data

The following code is to find the name Niladri from cell A1 to A5 and the find function will return A3 in output which is the address of the cell.

Finding-cell-number-for-niladri

1. Using After 

In this example, we are instructing the compiler to search for "Utsav" after cell A3.

Using-after-to-find-cell-address

2. Using LookIn 

LookIn function search in value, formulas, and comment.

value: It searches for the complete value in the cell if we are searching for "orange" then the ranged cell should contain the complete value "orange".

formulas: It searches for the value which can be generated by any formula or function like left("orange",4)  will return or if it is present in any one of the ranged cells then it will return the address of that cell.

comment: It that whether the searched value contains in the comment box or not.

Let's take a sample of data,

Data-sample

Code with three different parameters of LookIn.

Three-different-parameters-of-lookin

3. Using LookAt

In this function, we have two parameters one is xlWhole and xlPart.

xlWhole: Searched value should be in the entire range.

xlPart: Searched value should have to match with a part of the cell.

Let's take a sample of data,

Data-sample

Code to search the word "Tube" in the whole part of the cell.

Searching-tube-in-cell

Code to search the word "Tube" in some part of the cell.

Code-to-search-word-in-cell

4. Using SearchOrder

With the help of this function, we can tell VBA to search according to row or column. Let's take a sample of the data.

Data-sample

Code to search "Ayush" row-wise and column-wise.

Searching-row-wise-and-column-wise

5. Using SearchDirection

With the help of this function, we can tell VBA to search forward or backward, like if we want to search in A1:A5 and we are using xlNext then VBA will search in the following order ⇢ A1, A2, A3, A4, A5. If we are using xlPrevious then VBA will search in the following order ⇢ A5, A4, A3, A2, A1. Let's take a sample of data:

Data-sample

To Search "Ayush" using xlNext the code will return A4 and by using xlPrevious it will return A6.

Searching-ayush-name

6. Using MatchCase

This function tells VBA whether to be case sensitive (i.e. to differentiate between capital letters and small letters) or not if MatchCase is true then VBA will consider case sensitivity and if it is false then it will not consider case sensitivity. Let's take a sample of data:

Data-sample

If we want to search for "Ayush" and MatchCase is true then it will return A6 and if MatchCase is false then it will return A4.

Searching-ayush-name

7. Using WildCard

The "*" symbol is used to represent more than one character. For example, "A*" VBA will search for a word that starts with A, "*a" VBA will search for a word that ends with a. Let's take a sample of data:

Data-sample

The following code is to search for A1 and A2,

Searching-for-A1-and-A2
Comment

Explore