Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Air Lancer
 
Posts: n/a
Default Displays statements in Subcript or superscript using "If" formula

Hi all,

how do i create a "if" statement that displays words in subcript or
superscript?

e.g. = if (A1A2, "Pa Pb", "Pb Pa"), where the "a" and "b" should be
displayed as subscripts to "P".

thk.
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Excel doesn't support this kind of formatting for formulas.

Air Lancer wrote:

Hi all,

how do i create a "if" statement that displays words in subcript or
superscript?

e.g. = if (A1A2, "Pa Pb", "Pb Pa"), where the "a" and "b" should be
displayed as subscripts to "P".

thk.


--

Dave Peterson
  #3   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

Air,

You have to do that using VBA code.

For example, copy the code below, right-click on the sheet tab where you want that IF function,
select "View Code", and paste the code into the window that appears.

Change the "A3" to reflect the cell address of the cell where you wanted that formula.

If you have no other formulas, you might need to use the change event instead.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Calculate()
Application.EnableEvents = False
With Range("A3")
If Range("A1").Value Range("A2").Value Then
.Value = "Pa Pb"
ElseIf Range("A1").Value < Range("A2").Value Then
.Value = "Pb Pa"
Else
.Value = "Pa = Pb"
End If
.Characters(Start:=2, Length:=1).Font.Subscript = True
.Characters(Start:=7, Length:=1).Font.Subscript = True
End With
Application.EnableEvents = True
End Sub



"Air Lancer" wrote in message
...
Hi all,

how do i create a "if" statement that displays words in subcript or
superscript?

e.g. = if (A1A2, "Pa Pb", "Pb Pa"), where the "a" and "b" should be
displayed as subscripts to "P".

thk.



  #4   Report Post  
Air Lancer
 
Posts: n/a
Default

it works. THX!

"Bernie Deitrick" wrote:

Air,

You have to do that using VBA code.

For example, copy the code below, right-click on the sheet tab where you want that IF function,
select "View Code", and paste the code into the window that appears.

Change the "A3" to reflect the cell address of the cell where you wanted that formula.

If you have no other formulas, you might need to use the change event instead.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Calculate()
Application.EnableEvents = False
With Range("A3")
If Range("A1").Value Range("A2").Value Then
.Value = "Pa Pb"
ElseIf Range("A1").Value < Range("A2").Value Then
.Value = "Pb Pa"
Else
.Value = "Pa = Pb"
End If
.Characters(Start:=2, Length:=1).Font.Subscript = True
.Characters(Start:=7, Length:=1).Font.Subscript = True
End With
Application.EnableEvents = True
End Sub



"Air Lancer" wrote in message
...
Hi all,

how do i create a "if" statement that displays words in subcript or
superscript?

e.g. = if (A1A2, "Pa Pb", "Pb Pa"), where the "a" and "b" should be
displayed as subscripts to "P".

thk.




  #5   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

Air,

Glad to hear that you were actually able to follow my poorly-written instructions.... ;-)

Bernie
MS Excel MVP


"Air Lancer" wrote
it works. THX!





  #6   Report Post  
jahoobob
 
Posts: n/a
Default


As far as I know, it can't be done because Excel only allows formatting
at the cell level, not the characete level like Word.
Air Lancer Wrote:
Hi all,

how do i create a "if" statement that displays words in subcript or
superscript?

e.g. = if (A1A2, "Pa Pb", "Pb Pa"), where the "a" and "b" should
be
displayed as subscripts to "P".

thk.



--
jahoobob
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking two IF statements together trixma Excel Discussion (Misc queries) 2 September 29th 05 06:07 AM
how do i superscript part of a cell in MS Excel? allan Excel Discussion (Misc queries) 8 July 20th 05 10:37 PM
how do i superscript part of a cell in MS Excel? allan Excel Discussion (Misc queries) 0 July 13th 05 08:12 PM
Nested IF statements John Simons Excel Worksheet Functions 14 February 16th 05 06:17 AM
Formula window displays correct answer while cell displays incorre MMV Excel Worksheet Functions 3 November 10th 04 09:28 PM


All times are GMT +1. The time now is 07:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"