I would like to use a concatenate formula in Excel that also includes the superscript number 2 (squared symbol), but this does not work with the following input. The formula is roughly like this:
=CONCATENATE("13";"²")
i want to get an output like this:
13²
I tried using superscript functions on the font
but it didn't work when the text is inside the concatenation.
I have to use concatenate because I want to automate.
Is it possible to do with Excel 2019 there? or is it possible but would require VBA?
Try
=CONCATENATE("13";CHAR(178))
Using superscript digits via udf
Superscript digits ranging from 0 to 9 have code values in different unicode sections. Thus using the following user defined function (udf) allows you to get each digit from 0 to 9 as superscript character without the need to detect & memorize each code value again and again.
The hexadecimal and decimal codes are commented in the function below:
Function sup(ByVal digit As Long)
Dim n As Long
Select Case digit
Case 0: n = &H2070 ' dec 8304
Case 1: n = &HB9 ' dec 185
Case 2: n = &HB2 ' dec 178
Case 3: n = &HB3 ' dec 179
Case Else ' <super> 4 .. 9
n = &H2074 + digit - 4 ' dec 8308 .. 8313
End Select
sup = ChrW(n)
End Function
Some examples (~~> output x³)
="x" & sup(3)
=CONCAT("x",sup(3))
=CONCAT("x",sup(Sheet1!A2)) ' assuming a digit value of 3 in Sheet1!A2
or within VBA assignments like e.g.
Sub ExampleCall()
Dim i As Long
For i = 0 To 9
Sheet1.Range("A2").Offset(i).Value = "x" & sup(i)
Next
End Sub
I also found a way to make this work without using concatenate, it just requires making a table to map to superscript numbers.
Step 1: Characters Table
Somewhere else, build a simple table with a map from "Digit" numbers to "Superscript" numbers.
In the first column, "Digit", just type something like:
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
In the second column, "Superscript", go to Excel Ribbon Insert > Symbol. In the tab "Symbol", change the comboboxes "Font" to "(normal text)" and "Subset" to "Superscripts and Subscripts". Insert now each character in its corresponding cell be sure to use "Superscript Minus" for negative numbers. Superscripts 1, 2 and 3 are located in the subset "Latin-1 Supplement".
-9 ⁻⁹
-8 ⁻⁸
-7 ⁻⁷
-6 ⁻⁶
-5 ⁻⁵
-4 ⁻⁴
-3 ⁻³
-2 ⁻²
-1 ⁻¹
0 ⁰
1 ¹
2 ²
3 ³
4 ⁴
5 ⁵
6 ⁶
7 ⁷
8 ⁸
9 ⁹
And so on. Please notice that these are not "formatted" numbers, but special symbols with no numeric value.
Step 2: Vlook Function
Put the digit you want displayed normally in a column, set up like it is in 'A1' below, i.e.:
Cell A1: 13
Then, put the number you want to be displayed in superscript format, i.e.:
Cell B1: 3
Then, use this function to create the final output.
Cell C1: =A1&VLOOKUP(B1,Sheet2!$A$1:$B$20,2,FALSE)
Related
I'm having a data set with different length of string and they get concatenated into a separate column to be made equal via LEN(), TRIM() and REPT().
The formulas I used can be seen in the last row for each column (B:E).
Althought the length of the final string is equal, one can see that the strings within the "Name with equal length" column are not optically identical/ of "same" length.
As I want to use this column for making new file names via VBA, I wanted to explicitly have file names with "optically smooth names". (I hope you get what I mean.)
How can I achieve this? Do I have to calculate the pixel differences within (case-sensitive) letters? If so, how can I do this?
Text
Place
Length of String
Needed Spaces
Name with equal length
Length of Name
SaMPLE_TEXT
P 1
12
2
SaMPLE_TEXT--P 1_.pdf
22
SaMPLE_TexT
P 2
13
1
SaMPLE_TexT-P 2_.pdf
22
SaMPLE_text
P 3
13
1
SaMPLE_text-P 3_.pdf
22
sample_TEXT
P 4
12
2
sample_TEXT--P 4_.pdf
22
SaMPLE_TEXT
P 5
12
2
SaMPLE_TEXT--P 5_.pdf
22
=LEN(TRIM(B1))
=MAX($D$1:$D$6)-LEN(TRIM(B2))+1
=TRIM(A2)&REPT("-";D2)&TRIM(B2)&"_.pdf"
=LEN(E2)
I would need to get the average of the 2nd to the 8th nonzero value per row. Meaning, it would always move depending where the nonzero begins at.
I think what I would need is to determine the following:
Location of the 2nd nonzero value
Location of the 8th nonzero value
Average of numbers between 2nd and 8th nonzero values
Is that possible?
For example
0 | 6 | 10 |5| 9 | 0 | 6 | 0 |3 | 10| 1|9|
Those in bold have to be averaged. The zeroes in between have to be ignored
If you are using Windows Excel 2019, then:
=AVERAGE(FILTERXML("<t><s>" &TEXTJOIN("</s><s>",TRUE,IF(row_ref<>0,row_ref,""))&"</s></t>","//s[position()>1 and position()<10]"))
TEXTJOIN extracts only those values which are non-zero (and non-blank)
By using the appropriate delimiters, we create an XML
The xPath with the position function then extracts the 2nd to 8th values (positions 2 through 9)
AVERAGE
Assuming your data is laid out as per the example below, place the following formula in column T and copy down as required.
=IFERROR(AVERAGE(INDEX(22:22,AGGREGATE(15,6,COLUMN(B22:S22)/(B22:S22<>0),ROW($2:$9)))),"Less than " & rows($2:$9) & " non zero numerical entries")
B22:S22 - represents the row of data you are looking at. Feel free to change the column reference letters to suit your needs. Just ensure all the references with in the formula match.
$2:$9 - Represents the number of entries you want to use as part of the average. 2 is the starting number that you want to use and corresponds to 2nd non zero. 9 is the last number you want to include and makes a total of 8 numbers. Adjust these number to change the data range you want to include.
Ensure you keep the $ to prevent the row number from changing as the formula is copied.
Aggregate performs array like operations. As a result it may cause your system to bog down or crash if there is an excessive number of rows you are looking at. Also, full column references should generally be avoided within the aggregate function to avoid excess calculation.
I placed my answer not in A1 to make sure it will work anywhere on your sheet.
Assuming a layout like this (your first row of numbers from D2 to T2):
Paste this to Y2 (in the combined) column:
=AVERAGEIF(OFFSET(C2,0,AGGREGATE(15,3,((D2:T2)>0)/((D2:T2)>0)*COLUMN(D2:T2)-COLUMN(C2),2)):OFFSET(C2,0,AGGREGATE(15,3,((D2:T2)>0)/((D2:T2)>0)*COLUMN(D2:T2)-COLUMN(C2),8)),">0")
Then copy down to the other rows.
Data I used:
1 2 0 6 4 9 0 7 3 7 1 1 1 2 6 9 7
0 0 7 0 1 1 4 4 1 5 8 3 5 6 4 6 4
1 7 2 8 0 6 4 9 9 7 8 4 6 9 4 2 9
0 1 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0
8 7 8 4 10 0 2 2 10 4 4 8 3 3 0 4 10
In this formula, C2 is the cell (empty or not) before the beginning of the row of numbers and not included in the numbers to be counted.
Assuming you have excel 365, this can be easily done using simply FILTER, INDEX and AVERAGE function
=AVERAGE(INDEX(FILTER(row_ref,row_ref>0),{2,3,4,5,6,7,8,9}))
Example
=AVERAGE(INDEX(FILTER(B5:N5,B5:N5>0),{2,3,4,5,6,7,8,9}))
I have the following numbers in the range AI3:AJ41:
34 3
26 3
25 3
24 2
24 2
24 2
24 2
24 2
24 2
24 2
24 2
24 2
22 2
22 2
22 2
22 2
21 2
21 2
21 2
21 2
19 2
19 2
19 2
19 2
19 2
19 2
19 2
19 2
17 2
17 2
17 2
15 2
15 2
15 2
15 2
12 1
12 1
12 1
12 1
The AI column contains values while the AJ column contains the following formula in cell AJ3:
=ROUNDUP(AI3/12,0)
which spans down to AI41.
In cell AJ2 I have the following sum formula
=SUM(AJ3:AJ41)
which results in 77.
I want to write a formula into cell AI2, to get the same result as I now have in AJ2 without using the (helper) column AJ i.e. only using the values of the AI column.
Maybe it can be a VB macro to do is, i don't know...
I've provided a link to my Sample File for easy copy/pasting.
Thank you for your time & help.
Updated November 27
I'm still at an airport, and decided to do this problem a stab without VBA/UDF.
An Array function can get you what you want. Type this into your worksheet with CTL SHIFT ENTER for a non-vba solution:
=SUM(ROUNDUP(COUNTIF(A1:AH1,">="&ROW(INDIRECT("A1:A"&MAX(A1:AH1),TRUE)))/12,0))
You can download XLSM file here.
For anyone who ever wishes they could perform VBA "loops" in a regular Excel formula, this is a pretty good example of how to approach as this essentially "loops" through the range with a higher integer each time by using the Row and Indirect functions. Chip Pearson's sight is brilliant for stuff like this.
UPDATED Nov 26
I am sitting bored in an airport, so I will give this another go... I think this custom function will get the OP what they want. Put this in anywhere and you'll get 77. =UMutCustom2(A1:AH1)
The custom function code needed is here:
Function UMutCustom2(rng As Range) As Double
Dim r As Long
For r = 1 To Application.WorksheetFunction.Max(rng)
UMutCustom2 = Application.WorksheetFunction.RoundUp(Application.WorksheetFunction.CountIf(rng, ">=" & r) / 12, 0) + UMutCustom2
Next r
End Function
original Answer
I included both of these examples in a file here.
Probably easiest to use an array formula. In cell Ai1 put this formula: =SUM(ROUNDUP(AI3:AI999/12,0))
However, after typing the formula YOU MUST HIT CTR SHIFT ENTER!
This will create curly brackets around the formula so when you view the formula it should appear: {=SUM(ROUNDUP(AI3:AI999/12,0))} and does sum to 77 on my version of file.
(good news is that in 2019 Excel's new query engine will not require the CTL SHIFT!)
Alternatively, if you want to make a custom function using vba, you could use this custom function, that would not require ctr shift enter... here's VBA code to make that:
Function UMuTCustomFunc(rng As Range) As Double
Dim ws As Worksheet, rCell As Range
Set ws = Sheets(rng.Parent.Name)
For Each rCell In Intersect(ws.UsedRange, rng).Cells
UMuTCustomFunc = Application.WorksheetFunction.RoundUp(rCell.Value / 12, 0) + UMuTCustomFunc
Next rCell
End Function
Sumproduct
If you don't want to use an array formula (too lazy to press CTRL SHIFT ENTER) you can use:
=SUMPRODUCT(ROUNDUP(AI$3:AI$41/12,0))
and press ENTER. The result is 77.
Funny
I didn't even know there was a ROUNDUP function so I used this at first:
=SUMPRODUCT(IF(MOD(AI3:AI41,12)=0,INT(AI3:AI41/12),INT(AI3:AI41/12)+1))
but it doesn't work without entering it as an array formula. This should serve as a reminder that even SUMPRODUCT won't always work as a 'non-array' formula.
Addition
If you want to apply the same principle to the range A1:AH1, use this formula:
=SUMPRODUCT(ROUNDUP($A1:$AH1/12,0))
The result is 87 though.
I have an excel worksheet with something like below. The desired output are as shown in column G and the last row, which concatenates all the values in columns/rows and gives the value of the resultant expression.
It's actually some kind of a puzzle where the aim is to replace some numbers with operators such that the values in G matches with a specified value. I am replicating the same in excel from a paper version.
A B C D E F G
3 3 33
4 1 + 2 43
4 0 + 5 6 4 604
7 3 2 / 1 2 61
3 7 2 7 3727
3 0 30
47 4033 304 0.4 2617 42
I have tried the following formula:
="="&A2&B2&C2&D2&E2&F2
However it gives the result in text format instead of 43, which I expected:
=41+2
Is there any way to give the final output as 43.
I developed (recorded and modified) a macro which simply copies the above result, paste it as values in Column H and then run 'text to columns' on the column H which gives me the desired output exactly as expected. However, I still can't figure out how to do the same with the row.
Is there any way to achieve the above with a formula only?
I want to avoid using macros as the undo functionality is lost but suggestions are welcome.
You could create a UDF that uses Application.Evaluate to evaluate the text string into a value. Then your formula would just need =Eval(A2&B2&C2&D2&E2&F2)
Function Eval(txt As String)
Eval = Application.Evaluate(txt)
End Function
I have a line of numbers from 0 to 100. They follow each other like usual:
1 2 3 4 5 6 7 8 9 10 ... and so on --> ... 100
But I need to change their direction from right to left, like this:
100 <-- and so on ... 10 9 8 7 6 5 4 3 2 1 0
Is there some special tool for this operetion?
Each number is in its individual cell and horizontally: 1 in [A1], 2 in [B1], 3 in [C1], and so on.
If this is exaclty what you need, you can simply enter 100 in A1, 99 in B1, select the 2 cells and drag the formula to the right (by clicking on the little square at the bottom right of the selected range).
If your actual problem is a bit more complex and you need to sort the data in descending order, you could:
transpose it to make it vertical (Copy / Paste Special and select transpose)
sort the data set with the standard sorting feature
transpose it again back to its original range