C
Carolyn
Hello,
I want to create a macro to test across a range of cells. In the below
attempt at the code, I assumed that the user has highlighted the desired
block. I want to test the contents of each cell, and to format superscript
only aphabetic characters (not numeric, and certainly not the entire cell).
The data I'm working with is primarily numeric, and any alphabetic characters
are a statistics notation. It would greatly save our graphics folks time to
have this macro that will superscript all alphabet characters while not
touching the numeric characters.
I cobbled together the below code based on code I found on F. David
McRitchie's webpage (http://www.mvps.org/dmcritchie/excel/join.htm). It kinda
works. But it only superscripts alpha characters the first cell in the
highlighted range. I need it to superscript for all cells in the highlighted
range.
Option Explicit
Sub SuperscriptLetters()
Dim cell As Range
Dim i As Integer
On Error Resume Next 'in case nothing found
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
If Len(cell) > 0 Then
For i = Len(cell) To 1 Step -1
If Mid(cell, i, 1) = "A" Then
With ActiveCell.Characters(Start:=i, Length:=1).Font
.Superscript = True
End With
End If
Next i
End If
Next cell
End Sub
Thank you in advance for any assistance!
Carolyn
I want to create a macro to test across a range of cells. In the below
attempt at the code, I assumed that the user has highlighted the desired
block. I want to test the contents of each cell, and to format superscript
only aphabetic characters (not numeric, and certainly not the entire cell).
The data I'm working with is primarily numeric, and any alphabetic characters
are a statistics notation. It would greatly save our graphics folks time to
have this macro that will superscript all alphabet characters while not
touching the numeric characters.
I cobbled together the below code based on code I found on F. David
McRitchie's webpage (http://www.mvps.org/dmcritchie/excel/join.htm). It kinda
works. But it only superscripts alpha characters the first cell in the
highlighted range. I need it to superscript for all cells in the highlighted
range.
Option Explicit
Sub SuperscriptLetters()
Dim cell As Range
Dim i As Integer
On Error Resume Next 'in case nothing found
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
If Len(cell) > 0 Then
For i = Len(cell) To 1 Step -1
If Mid(cell, i, 1) = "A" Then
With ActiveCell.Characters(Start:=i, Length:=1).Font
.Superscript = True
End With
End If
Next i
End If
Next cell
End Sub
Thank you in advance for any assistance!
Carolyn