![]() |
How to change a value in a cell based on finding value in another
I want to perform a search of entire spreadsheet and when a specified value
is found a replace is performed in a specified cell of a specified value. I want to code this in VB to be used as a macro. |
How to change a value in a cell based on finding value in another
|
How to change a value in a cell based on finding value in another
This might work. You will have to change a couple of items in the code where
I have so noted. Sub srchWks() Dim myRng As Range, myVar As Variant Dim RangeToChange As Range, newValue As Variant RangeToChange = Cells(5, 5) '<<< Change to actual newValue = "Hello" '<<< Change to actual Set myRng = ActiveSheet.UsedRange With myRng Set c = .Find(myVar, LookIn:=xlValues) '<<< Define myVar If Not c Is Nothing Then fRng = c.Address RangeToChange.Value = newValue End If End With End Sub "Laurie Born" wrote: I want to perform a search of entire spreadsheet and when a specified value is found a replace is performed in a specified cell of a specified value. I want to code this in VB to be used as a macro. |
All times are GMT +1. The time now is 02:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com