ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find and Replace (https://www.excelbanter.com/excel-programming/405480-find-replace.html)

molinaram

Find and Replace
 
Using VBA, is it possible to search a range for a value in one cell and
replace with a value in another cell? I have tried using the Record Macro
option and recorded the following (which, of course, does not work).

Application.Goto Reference:="SearchArea"
Cells.Replace What:=Range("R2C2"), Replacement:=Range("R2C3"),
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

How can I modify it to make it work?

Any help is greatly appreciated.


--
molinaram

JLGWhiz

Find and Replace
 
Sub rplc()
Cells.Replace What:=Range("B2").Value, Replacement:=Range("C2").Value,
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub


"molinaram" wrote:

Using VBA, is it possible to search a range for a value in one cell and
replace with a value in another cell? I have tried using the Record Macro
option and recorded the following (which, of course, does not work).

Application.Goto Reference:="SearchArea"
Cells.Replace What:=Range("R2C2"), Replacement:=Range("R2C3"),
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

How can I modify it to make it work?

Any help is greatly appreciated.


--
molinaram


molinaram

Find and Replace
 
Thank you, Thank you, thank you. This is going to be such a time saver.
--
molinaram


"JLGWhiz" wrote:

Sub rplc()
Cells.Replace What:=Range("B2").Value, Replacement:=Range("C2").Value,
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub


"molinaram" wrote:

Using VBA, is it possible to search a range for a value in one cell and
replace with a value in another cell? I have tried using the Record Macro
option and recorded the following (which, of course, does not work).

Application.Goto Reference:="SearchArea"
Cells.Replace What:=Range("R2C2"), Replacement:=Range("R2C3"),
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

How can I modify it to make it work?

Any help is greatly appreciated.


--
molinaram



All times are GMT +1. The time now is 09:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com