ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Formating a text string? (https://www.excelbanter.com/excel-discussion-misc-queries/860-formating-text-string.html)

METCO1

Formating a text string?
 
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?

Frank Kabel

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

--
Regards
Frank Kabel
Frankfurt, Germany

"METCO1" schrieb im Newsbeitrag
...
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?


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


In article ,
METCO1 wrote:

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?



All times are GMT +1. The time now is 12:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com