ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA to superscript a part of a cell (https://www.excelbanter.com/excel-programming/441721-re-vba-superscript-part-cell.html)

Dave Peterson

VBA to superscript a part of a cell
 
You may want to try John Walkenbach's addin:
http://j-walk.com/ss/excel/files/supersub.htm

Mikhail Bogorad wrote:

hi
i have a report that populates some text descriptions in cells range
B2:B15. So sometimes text has a date, for example "... October
1st...". What i want is to superscript letters "st" every time it
finds "1st".

Has anyone ever encountered this problem before?

Thanks


--

Dave Peterson

Mikhail Bogorad

VBA to superscript a part of a cell
 
On Apr 16, 8:04*am, Dave Peterson wrote:
You *may want to try John Walkenbach's addin:http://j-walk.com/ss/excel/files/supersub.htm

Mikhail Bogorad wrote:

hi
i have a report that populates some text descriptions in cells range
B2:B15. So sometimes text has a date, for example "... October
1st...". What i want is to superscript letters "st" every time it
finds "1st".


Has anyone ever encountered this problem before?


Thanks


--

Dave Peterson


Thanks guys, i'll test your suggestions and let you know. In my report
it can only be "1st" no "2nd" or "3rd" but thanks anyways.

Rick Rothstein

VBA to superscript a part of a cell
 
Thanks guys, i'll test your suggestions and let you know. In my report
it can only be "1st" no "2nd" or "3rd" but thanks anyways.


In that case, the macro code can be reduced to this...

Sub SuperScriptOrdinals()
Dim X As Long, Position As Long, C As Range
For Each C In Range("B2:B15")
Position = InStr(C.Value, "1st")
If Position Then C.Characters(Position + 1, 2).Font.Superscript = True
Next
End Sub

--
Rick (MVP - Excel)


All times are GMT +1. The time now is 03:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com