ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   replace text string in cell automatically (https://www.excelbanter.com/excel-programming/393398-replace-text-string-cell-automatically.html)

Stephen

replace text string in cell automatically
 
How could I replace a text string in cell programatically?
Tks

Norman Jones

replace text string in cell automatically
 
Hi Stephen,

How could I replace a text string in cell programatically?


Try something like:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range

Set WB = Workbooks("Book1") '<<==== CHANGE
Set SH = WB.Sheets("Sheet2") '<<==== CHANGE
Set Rng = SH.Range("A1:A10") '<<==== CHANGE

Rng.Replace What:="Bill", _
Replacement:="Ben", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
End Sub
'<<=============


---
Regards,
Norman




All times are GMT +1. The time now is 03:58 AM.

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