Formating a text string?

M

METCO1

I use subscripting in Excel for text cells, but would like to subscript in a
text string that includes numbers. For example, I need to subscript the "x"
in Standard Deviation = 0.125 lbs/hr NOx. Is there a way of doing this?
 
F

Frank Kabel

Hi
select this character in the formula bar and goto format - cells

--
Regards
Frank Kabel
Frankfurt, Germany

METCO1 said:
I use subscripting in Excel for text cells, but would like to subscript in a
text string that includes numbers. For example, I need to subscript the "x"
in Standard Deviation = 0.125 lbs/hr NOx. Is there a way of doing
this?
 
J

JE McGimpsey

You can't use subscripting in a cell with a formula.

You could use an event macro to build the text string and format it.
Assume your formula is


="Standard Deviation = " & STDEV(B1:B100) & " lbs/hr NOx"

Put something like this in the worksheet code module (right-click the
worksheet tab and choose View Code):

Private Sub Worksheet_Calculate()
Const STEXT = "Standard Deviation = $$ lbs/hr NOx"
Dim sStdDev As String

sStdDev = Format(Application.StDev(Range("B1:B100")), "0.000")
With Range("A1")
.Value = Application.Substitute(STEXT, "$$", sStdDev)
.Characters(Len(.Text), 1).Font.Subscript = True
End With
End Sub

Change your ranges to suit.


If you're not familiar with macros, see David McRitchie's "Getting
Started with Macros":

http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top