How do i prevent the 2nd Instance of patricular String being Replaced using REPLACE Function

NimishK

Well-known Member
Joined
Sep 4, 2015
Messages
684
Hello

How do i prevent the 2nd Instance of patricular String being Replaced using REPLACE Function

For Eg
Amount 75000.00
ID Number 2229400331
Status Amount Trfd

so i would like to prevent string Amount being replaced in line Status Amount Trfd

using the Below code

VBA Code:
Dim Strline As String
         Strline = Replace(Strline, "Amount", vbCrLf & "AMOUNT")
         Strline = Replace(Strline, "ID Number", vbCrLf & "ID NUMBER")
         Strline = Replace(Strline, "Status", vbCrLf & "STATUS")

I get below result
AMOUNT 75000.00
ID NUMBER 22229400331
STATUS Amount Trfd
AMOUNT Trfd
Instead of
AMOUNT 75000.00
ID NUMBER 22229400331
STATUS Amount Trfd

Your help will be appreciated

NimishK
 
Alex Sir,

Indeed the perfect coding by you. It Resolved what i desired

Thank you so much for your time and efforts to get this resolved
🙏 :)🥂

and Thanks to members who also posted their logic to this thread🙏

NimishK
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,215,020
Messages
6,122,712
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top