Superscript Formula in Excel Function CONCATENATE

Click For Summary
The discussion focuses on using Excel's CONCATENATE function to format chemical reactions with superscripts for isotopes. The user seeks to combine mass numbers as superscripts above their respective symbols in a single line, which CONCATENATE cannot achieve. Suggestions include using multiple columns, but this would disrupt the organization of reactions. The conversation shifts to using VBA as a solution, with shared code snippets aimed at formatting the output correctly. The user is encouraged to modify the provided VBA code to suit their specific reaction formatting needs.
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
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
Replies
1
Views
3K
  • · Replies 10 ·
Replies
10
Views
5K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 48 ·
2
Replies
48
Views
10K