Find text and replace it with Superscript

Chandresh

Board Regular
Joined
Jul 21, 2009
Messages
146
Hi Team,
Could you please help me with a macro that can find specific text and replace it with Superscript.

Example :

1693993517290.png


Thanks in advance for your help.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
That's a bit vague so my answer won't be as focused as you would no doubt like it to be.
Find where? Within a row? Column? A sheet? The whole workbook? Just within a string? How many characters might come after % sign?
Perhaps this will get you started
Once you have found a range that contains the value (I'm guessing that is only going to be a percent sign) you can format that portion using functions like InstrRev to locate the % sign. Using a sheet/range reference as an example, this will find the % in your sample:
instrrev(Sheets("4").range("B1"),"%") which will equal 3 when the cell contains "20%1". Add 1 to that so that you locate the next character to be formatted as superscript:
Sheets("4").range("B1").characters(instrrev(Sheets("4").range("B1"),"%")+1,1).font.superscript = true
The red 1 tells the expression to format only one character after the %, so if that's not the case, then more needs to be done to determine the length - again, not revealed yet.

If you use code that returns a range object (like the code at the link) you'd substitute the sheet/range reference below with the range object.
Mid(Sheets("4").range("B1"),instrrev(Sheets("4").range("B1"),"%")+1)
 
Upvote 0

Forum statistics

Threads
1,225,482
Messages
6,185,259
Members
453,283
Latest member
Shortm88

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