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

Change String

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)
25 views1 page

Change String

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
You are on page 1/ 1

https://learn.microsoft.com/en-us/office/vba/api/excel.range.

find

Private Sub Worksheet_Change(ByVal Target As Range)

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

Dim Val As String


Val = Target.Value
MsgBox Val

Dim c As Range
Dim firstAddress As String

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

You might also like