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

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,213,517
Messages
6,114,089
Members
448,548
Latest member
harryls

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