Forum Discussion
Ituah_Imafidon
Jun 25, 2025Copper Contributor
Complex Cell Format, Maybe!!!
Hi, I'm in the eyecare profession and we make use of vision measurement (visual acuity) standards, and these are supposed to be indivisible fractions, but here are what I's faced with: Unless I fo...
Ituah_Imafidon
Jun 29, 2025Copper Contributor
Thanks for the good alternative, but it has a little challenge. You see the visual acuity (6/12...), they tend sometimes to have superscripts, and when I follow the method above, it returns the superscript to an ordinary number.
E.g.: 6/12-2, the -2 is supposed to be in superscript format.
How can I remedy that, or is it impossible???
Thanks for your assistance.
JKPieterse
Oct 07, 2025Silver Contributor
If you are fine with a bit of VBA you can make this happen.
Right-click the worksheet's tab and choose "View Code". Paste this code in the window that opens:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count = 1 Then
TurnIntoSuperScript Target
End If
End Sub
Next, from the menu, choose Insert, Module. Paste in this code:
Sub TurnIntoSuperScript(cl As Range)
Dim val As Variant
Dim pos As Long
val = cl.Value
pos = InStr(val, "-")
If pos > 0 Then
With cl.Characters(Start:=1, Length:=pos - 1).Font
.Superscript = False
End With
With cl.Characters(Start:=pos, Length:=Len(val) - pos + 1).Font
.Superscript = True
End With
Else
cl.Font.Subscript = False
End If
End Sub
Now try entering a fraction into a cell on the worksheet.