ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find a string between two delimeters and replace with text (https://www.excelbanter.com/excel-programming/360253-find-string-between-two-delimeters-replace-text.html)

Jeff[_50_]

Find a string between two delimeters and replace with text
 
I have a range of cells in which I must replace a string between ":" and ")"
with a new a new string.

Thanks in advance for your ideas.



Chip Pearson

Find a string between two delimeters and replace with text
 
Try some code like the following

Dim S As String
Dim Pos1 As Long
Dim Pos2 As Long
S = "123:asdf)abs"
Pos1 = InStr(S, ":")
Pos2 = InStr(S, ")")
S = Left(S, Pos1 - 1) & "new text" & Mid(S, Pos2 + 1)
Debug.Print S


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jeff" wrote in message
...
I have a range of cells in which I must replace a string between
":" and ")"
with a new a new string.

Thanks in advance for your ideas.





Jeff[_50_]

Find a string between two delimeters and replace with text
 
Thanks,Chip. How do I get 'S' to refer to the active cell in which I want
to replace the tect?




All times are GMT +1. The time now is 05:51 AM.

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