Superscript Formula in Excel Function CONCATENATE

Click For Summary

Discussion Overview

The discussion revolves around the use of the CONCATENATE function in Microsoft Excel to format chemical reaction equations, specifically incorporating superscripts for isotopes. Participants explore various methods to achieve the desired formatting, including the use of VBA for more complex formatting needs.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant describes their attempt to format chemical reactions using the CONCATENATE function but expresses the need for superscripts for mass numbers.
  • Another participant questions the feasibility of combining superscripts and normal text within a single cell and suggests using multiple columns instead.
  • A participant acknowledges the suggestion of using multiple columns but raises concerns about maintaining the order of reactions.
  • Some participants propose using VBA as a solution to achieve the desired formatting, sharing snippets of code to illustrate their ideas.
  • Further discussion includes refining the VBA code to ensure proper formatting of superscripts in the context of chemical reactions.

Areas of Agreement / Disagreement

There is no consensus on the best method to achieve the desired formatting. Participants present multiple approaches, including using CONCATENATE, multiple columns, and VBA, with varying opinions on their effectiveness.

Contextual Notes

Participants note limitations regarding the ability to format text within a single cell and the complexity of using VBA for specific formatting needs. There are also unresolved aspects regarding the implementation of the VBA code for different rows.

parazit
Messages
75
Reaction score
3
Hello Master.

I would like to ask a question about MS Excel and one of it's functions; CONCATENATE.

I'm trying to write a huge number of reactions in the Excel as the following form : 12C (α,p) 15N

So, since I have tons of reactions to organize according to the alphabetic order and isotopes I decided to use excel cells as following. (in parentheses, the values of upper reaction)

A1 : Target isotopes mass number ( 12 )
B1 : Target symol ( C )
C1 : Incoming particle ( α )
D1 : Outgoing particle ( p )
E1 : Product isotopes mass number ( 15 )
F1 : Product symbol ( N )

and used
Code:
=CONCATENATE(A1;B1;"(";C1;",";D1;")";E1;F1)
to write them in the form.

However, this is not true since I need that, cells A1 and E1 have to be written as the superscripts of cells B1 and F1 respectively in the same line.

Are there any way to do that ? I am open to any suggestion either solving this problem or a new, different way to let me write that tones of reactions in a suitable order.

Thank you,
Best.
 
Physics news on Phys.org
I'm not even sure if combining superscripts and normal font size in the same cell is possible at all. You could use multiple columns for your formula, the first and third with superscript and the others with normal font.

By the way: instead of CONCATENATE, you can also use the shorter =A1&B1&...
 
mfb said:
I'm not even sure if combining superscripts and normal font size in the same cell is possible at all. You could use multiple columns for your formula, the first and third with superscript and the others with normal font.

By the way: instead of CONCATENATE, you can also use the shorter =A1&B1&...

Thanks for the advise about the shorter way. I'm aware of that but I think if I use concatenate, I'll be able to make superscripts more easily, which I won't be able.

About multiple cells idea; it seems it's not going to work since in that way, the reaction equation will be parted and I won't be able to order all the reactions. (or am I wrong? I really do not know)
 
pasmith said:
It can be done using VBA (in Excel 2003 at least).

Dear pasmith, thank you so much. It gives me an inspiration. I also found that on the web.

Yes, it was done before using VBA but not exactly in the way that I need and suitable for reaction indication.

The code that I found is like that :
Code:
Sub test()
Range("C1").ClearContents
Range("C1").Value = Range("A1").Value & Range("B1").Value
For i = 1 To Len(Range("A1").Value)
    If Range("A1").Characters(i, 1).Font.Bold = True Then Range("C1").Characters(i, 1).Font.Superscript = True
Next i
For j = 1 To Len(Range("B1").Value)
If Range("B1").Characters(j, 1).Font.Superscript = True Then Range("C1").Characters(j + Len(Range("A1").Value), 1).Font.Superscript = True
Next j
End Sub

in where the value of cell A2 becomes a right superscript of the value in cell A1 and they all written to cell A3.

However, the reaction indication is not like that. So, can somebody please help me to re-arrange the code according to the reaction form.

Please do not withhold your ideas and knowledge.

Best.
 
The "end" of superscripts seems to be a bit messy, so I would make them one by one:
Code:
For i = 1 To Len(Range("G1").Value)
    If i <= Len(Range("A1").Value) Or (i >= lengthABCD And i < lengthABCD + Len(Range("E1").Value)) Then
        Range("G1").Characters(i, 1).Font.Superscript = True
    Else
        Range("G1").Characters(i, 1).Font.Superscript = False
    End If
Next i
Where lengthABCD is the sum of the length of the first four cells which has to be calculated first (and G1 has to be filled first, too).

You'll also have to generalize this to work with every row instead of just the first one.
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 10 ·
Replies
10
Views
5K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 48 ·
2
Replies
48
Views
11K