1

How do I write function for replace multiple alphabets in one cell, I want to change "space" to "%20", " ' " to "%27", "+" to "%2B"

an example as in the image below

example

1 Answers1

2

Using nested SUBSTITUTEs:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," ","%20"),"'","%27"),"+","%2B")

enter image description here

BigBen
  • 46,229
  • 7
  • 24
  • 40
  • Since you put this answer, I dupped this question as now it has just about all approaches covered. – Scott Craner Apr 19 '22 at 13:59
  • @ScottCraner Sir, there are other approaches as well, who knows it can be done with Power Query as well, ! – Mayukh Bhattacharya Apr 19 '22 at 14:01
  • 1
    @MayukhBhattacharya it can be done with powershell too, but those are outside the scope of this question as it asked for formula answers. The dup and this answer cover the formula tag. There may still be answers that use formula, feel free to add answers to the dup. – Scott Craner Apr 19 '22 at 14:06
  • Sir, why can't I use that function, when I write it, it doesn't produce results but only writes =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A$1," ","%20"),"'","%27"),"+","%2B") what's wrong with my excel, why it works for you it doesn't work for me – Nata_The_Coco Apr 19 '22 at 14:07
  • @Nata_The_Coco may the cells are formatted as TEXT change it to general – Mayukh Bhattacharya Apr 19 '22 at 14:07
  • @ScottCraner Sir, may be OP is not aware of Power Query, but PQ is very much part of Excel. But for me i would have followed what BigBen Sir shared or the one JvdV Sir, shared and now since you have shared with VBA its more than enough. – Mayukh Bhattacharya Apr 19 '22 at 14:09