0% found this document useful (0 votes)
10 views1 page

Excel VBA Find and Replace Example

This document describes the Find method in Excel VBA which allows searching for a value or formula within a range and returning the first cell that matches. It can search for values, formulas, fonts, interior colors and more. The Find method returns a Range object representing the first cell that matches the criteria or Nothing if no match is found.

Uploaded by

DenisTitov
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Excel VBA Find and Replace Example

This document describes the Find method in Excel VBA which allows searching for a value or formula within a range and returning the first cell that matches. It can search for values, formulas, fonts, interior colors and more. The Find method returns a Range object representing the first cell that matches the criteria or Nothing if no match is found.

Uploaded by

DenisTitov
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

[Link]

find

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Columns("B")) Is Nothing Then

Dim Val As String


Val = [Link]
MsgBox Val

Dim c As Range
Dim firstAddress As String

With [Link]("Sheet1").Range("D2:E9")
Set c = .Find(Val, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = [Link]
Do
[Link] = Replace([Link], Val, "xyz")
Set c = .FindNext(c)
Loop While Not c Is Nothing
End If
End With
End If
End Sub

You might also like