Replacing character in a given string

mandukes

Forum Rules
Joined
May 25, 2013
Messages
90
Hi, I need to insert character in between a given string by replacing the character in the given string.


Here is an example:

Str = "ABTXDFATGTHYFL"

Replacing A with Z

So, the output would be "ZBTXDFZTGTHYFL"


Thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi, I need to insert character in between a given string by replacing the character in the given string.

Here is an example:

Str = "ABTXDFATGTHYFL"

Replacing A with Z

So, the output would be "ZBTXDFZTGTHYFL"

Thanks
Str is not a good name to use for a variable as that is the name of a built-in VB function. With that said, if...

Str = "ABTXDFATGTHYFL"

Then to "fix" it...

Str = Replace(Str, "A", "Z")
 
Upvote 0
Type str into the Immediate Window and then, with the text cursor in or next to the word, press the F1 key and you will see the help page for the Str function.

AAh, funny the VBA intelligence does not recognize Str() as I type it. but it sure does works ;) Thanks for pointing this out.

BTW, I,m using office 2016 X64
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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