Public Sub ValueTolerance2()
Dim rngSel As Range, rngTgt As Range
Set rngSel = Selection
'\\ Check if user has selected 3 columns and 1 row
If Not (rngSel.Columns.Count = 3 And rngSel.Rows.Count = 1) Then
MsgBox "Selection must be 3 columns by 1 row only!", vbInformation
Exit Sub
Else
If Application.CountA(rngSel) < 3 Then
MsgBox "One or more cells are empty!", vbInformation
Exit Sub
End If
End If
'\\ Select Range
On Error Resume Next
Set rngTgt = Application.InputBox(Prompt:="Select Target Cell!", Type:=8)
Err.Clear
On Error GoTo 0
'\\ Check if user has made valid selection or not.
If Not rngTgt Is Nothing Then
With rngTgt
.Value = rngSel.Cells(1, 1).Value & IIf(InStr(rngSel.Cells(1, 2).Value, "+") > 0, rngSel.Cells(1, 2).Value, "+" & rngSel.Cells(1, 2).Value) & _
IIf(InStr(rngSel.Cells(1, 3).Value, "-") > 0, rngSel.Cells(1, 3).Value, "-" & rngSel.Cells(1, 3).Value)
p1 = InStr(.Value, "+")
p2 = InStr(.Value, "-")
With .Characters(Start:=p1, Length:=p2 - p1).Font
.Superscript = True
.Subscript = False
End With
With .Characters(Start:=p2, Length:=Len(.Value) - p2 + 1).Font
.Superscript = False
.Subscript = True
End With
End With
Else
MsgBox "No cell selected for output!", vbExclamation
End If
End Sub