Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default VBA to superscript a part of a cell

On Thu, 15 Apr 2010 14:49:14 -0400, "Rick Rothstein"
wrote:

If I can anticipate your complete requirements (for 1st, 2nd, 3rd, nth),
give this macro a try after the cells have been filled in with their text...

Sub SuperScriptOrdinals()
Dim X As Long, NumPosition As Long, Cell As Range
For Each Cell In Range("B2:B15")
NumPosition = InStr(Cell.Value, "1st")
If NumPosition = 0 Then
NumPosition = InStr(Cell.Value, "2nd")
If NumPosition = 0 Then
NumPosition = InStr(Cell.Value, "3rd")
If NumPosition = 0 Then
For NumPosition = 1 To Len(Cell.Text)
If Mid(Cell.Value, NumPosition) Like "#th*" Then Exit For
Next
End If
End If
End If
If NumPosition Then
Cell.Characters(NumPosition + 1, 2).Font.Superscript = True
End If
Next
End Sub

--
Rick (MVP - Excel)


As you write, you are trying to anticipate the complete requirements.

But I note that your routine does not completely error check for incorrect
suffixes. For example, May 21th would have the "th" superscripted.



--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to superscript a part of a cell Peter T Excel Programming 4 April 16th 10 11:30 AM
VBA to superscript a part of a cell Gord Dibben Excel Programming 0 April 15th 10 11:12 PM
superscript in part of a string when using concatenate Ged2 Excel Discussion (Misc queries) 1 August 23rd 05 02:47 PM
how do i superscript part of a cell in MS Excel? allan Excel Discussion (Misc queries) 8 July 20th 05 10:37 PM
how do i superscript part of a cell in MS Excel? allan Excel Discussion (Misc queries) 0 July 13th 05 08:12 PM


All times are GMT +1. The time now is 07:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"