Is there a way to imbed a number in a text string, while still rounding it to millions and showing an 'm'?
If it was just formatting, I would use:
#.#,, 'm'
and in text I would use:
text(ref, "#.#,,")
but how can you combine the two? the below does not work
text(ref, "#.#,,m")
=TEXT(ROUND(ref,-6)/1000000,"#,##0")&"m"
This would round a number up to millions and then replace the 6 0's with the letter 'm'. e.g. 4,658,458,685 would become:
4,658m
Edit:
The following works as requested with everything inside the TEXT function:
=TEXT(ref, "#.#,," & """m""")
Related
I need to split(like divide) by 5, however each value should balance maximum possible way to each part
Example
6= 3,3 is ok. but 6= 5,1 is wrong
18= 5,5,4,4 is ok. but 18= 5,5,5,3 is wrong
21= 5,4,4,4,4 is ok. but 21= 5,5,5,5,1 is wrong
The underlying math for this is as follows. Number have to split will be split into repeats of two numbers. The smaller number is given by
=QUOTIENT(NUMBER_HAVE_TO_SPLIT,SPLIT_BY_PARTS)
and the larger number is given by
=QUOTIENT(NUMBER_HAVE_TO_SPLIT,SPLIT_BY_PARTS)+1
FYI the QUOTIENT worksheet function does integer division, e.g, QUOTIENT(13,4)=3.
The number of times the larger number is repeated is given by:
=MOD(NUMBER_HAVE_TO_SPLIT,SPLIT_BY_PARTS)
and the number of times the smaller number is repeated is given by:
=SPLIT_BY_PARTS - MOD(NUMBER_HAVE_TO_SPLIT,SPLIT_BY_PARTS)
The remaining task is to return the results in the formats you suggest. To get the comma-delimited format 3,4,4:
Convert both smaller number and larger number to text using TEXT(number,0)
Prepend each with a comma to give the strings ,3 and ,4
Use the REPT function to repeat each the appropriate number of times to give ,3 and ,4,4
Concatenate these two strings and use SUBSTITUTE to remove the first comma
A somewhat messy formula to accomplish the above is:
=SUBSTITUTE(REPT(","&TEXT(QUOTIENT(A2,B2),"0"),B2-MOD(A2,B2))&REPT(","&TEXT(QUOTIENT(A2,B2)+1,"0"),MOD(A2,B2)),",","",1)
where NUMBER_HAVE_TO_SPLIT and SPLIT_BY_PARTS are in A2 and B2, respectively.
A formula to generate the 3=1 and 4=2 format is
=TEXT(QUOTIENT(A2,B2),0)&"="&TEXT(B2-MOD(A2,B2),"0")&IF(MOD(A2,B2)>0," and "&TEXT(QUOTIENT(A2,B2)+1,0)&"="&TEXT(MOD(A2,B2),"0"),"")
I'm using the following formula to extract the number preceding an "x" from a string (e.g. ##x## where # equals a number 0-9) but with I have other words in the string that have an "x" in them, the formula doesn't work.
Here's the formula:
=IF(ISBLANK(A154),"",IFERROR(IF(VALUE(MID(A154,MIN(FIND({"1","2","3","4","5","6","7","8","9","0"},A154 & "(1,2,3,4,5,6,7,8,9,0")),FIND(INDEX(SET_TERMS,MATCH(1,COUNTIF(A154,"*"&$R$2:$R$5&"*"),0)),A154,1)-MIN(FIND({"1","2","3","4","5","6","7","8","9","0"},A154 & "(1,2,3,4,5,6,7,8,9,0"))))<=1,"",TRIM(MID(A154,MIN(FIND({"1","2","3","4","5","6","7","8","9","0"},A154 & "(1,2,3,4,5,6,7,8,9,0")),FIND(INDEX(SET_TERMS,MATCH(1,COUNTIF(A154,"*"&$R$2:$R$5&"*"),0)),A154,1)-MIN(FIND({"1","2","3","4","5","6","7","8","9","0"},A154 & "(1,2,3,4,5,6,7,8,9,0")))&" sets")),""))
Notes: SET_TERMS ($R$2:$R$5) is a list: rounds, set, sets, x.
Here are examples where the formula works fine:
Skater jumps 3x5 each side RESULT 3 sets
Russian Twist 3x30 seconds RESULT 3 sets
Push-ups 3x max RESULT 3 sets
Y holds 3x30 seconds RESULT 3 sets
Now, here are two examples of the strings that return a blank because Flexion and Extension have "x" in them:
Neck Flexion 3x20 seconds RESULT Blank
Neck Extension 3x20 seconds Result Blank
Any ideas on how to fix this?
Thanks
You just need to be more specific in what you are looking for.
For example, the following will return the digit prior to the x:
=MID(A1,MIN(FIND({0;1;2;3;4;5;6;7;8;9}&"x",A1&"0x1x2x3x4x5x6x7x8x9x")),1)
If you have Windows Excel 2013+ or O365, and you need to deal with multiple digit numbers, the following will extract space-separated "nodes" that have the pattern of ddx, where dd can be any number (including decimals). You can then use string functions to extract just the number.
=FILTERXML("<t><s>" & SUBSTITUTE(A1," ","</s><s>") & "</s></t>","//s[boolean(number(substring-before(.,'x')))]")
I have a comma separated list of values generated from an excel sheet. (Numbers and RTL Characters)
Having these values in columns: 1 | 2 | 3 | 4 | 5
would yield me the output of 1,2,3,4,5
But the issue arises when I have RTL characters (Persian/Arabic) in my columns: 1 2 ب الف and a 5 in the end.
Now the output becomes 1,2الف, ب, 5
Since my columns can have multiple sets of RTL characters it can really mess up the output to the point that it's no more trivial to fix it by substituting several inputs.
What are my options to produce a csv file with the right order?
Tools I used where javascript and excel and both had the same issue.
If your purpose is to only display the CSV for human eye, you can add RIGHT-TO-LEFT MARK () before each number:
1, 2, ب, الف, 5
1, 2, ب, الف, 5
Note that these characters may drive crazy any tool you use to parse the CSV.
I think your CSV file already has the right order. In the text you pasted in the question:
1,2الف, ب, 5
The "1" is the first character in the string, and the "5" is the last. It just doesn't seem that way to you because the first half of the string (1,2) is rendering LTR whereas the second half of the string (الف, ب, 5) is rendering RTL.
I've tried lots of searches for this but I'm still not coming up with anything that works.
I have a range of strings in Column A
Amend.Clause_1.1.AddMCQ
Amend.Clause_1.1.AddNo
Amend.Clause_1.1.AddRepeat
Amend.Clause_1.13.AddRepeat
Amend.Clause_1.13.AddTitle
Amend.Clause_1.13.AddUTQ
Amend.Clause_2.8.Heading_Edit
Amend.Clause_2.8.MCQ
Amend.Clause_2.8.Remove
Amend.Clause_4.26.AddUTQ
Amend.Clause_4.26.Heading_Edit
Amend.Clause_4.26.MCQ
Amend.Clause_5.15.AddMCQ
Amend.Clause_5.15.AddNo
Amend.Clause_5.15.AddRepeat
As you can see, the numbers always start in the same place, after the underscore "_" at position 13.
I need to extract the decimal numbers from these strings into a new column so I'm left with 1.1, 1.13, 1.14, 4.26 etc.
I've tried all sorts of combos of MID, LEFT, LEN, RIGHT but to no avail, trying to find the position of the last period.
Could anyone explain how to accomplish this? Ideally I'd like to do this without VBA.
Thanks
Here you are:
=VALUE(MID(A1,SEARCH("_",A1)+1,SEARCH(".",A1,SEARCH(".",A1,SEARCH("_",A1)+1)+1)-(SEARCH("_",A1)+1)))
Here's what inside =VALUE(MID(...)):
A1 - the whole string itself
SEARCH("_",A1)+1 - find the number starting position - right after "_".
SEARCH(".",A1,SEARCH(".",A1,SEARCH("_",A1)+1)+1)-(SEARCH("_",A1)+1) - find number length - position of second "." after first "." minus number starting position.
Try with three functions:
=MID(A1,14,FIND("#",SUBSTITUTE(A1,".","#",3))-14)
Try this - If the position of _ is not necessarily 13.
=MID(A1,FIND("_",A1,1)+1,FIND("¬¬",SUBSTITUTE(A1,".","¬¬",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))-FIND("_",A1,1)-1)
Or this if the _ is always 13
=MID(A1,14,FIND("¬¬",SUBSTITUTE(A1,".","¬¬",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))-14)
Use This:
=VALUE(TRIM(LEFT(SUBSTITUTE(RIGHT(A1;LEN(A1)-FIND("_";A1));".";REPT(" ";LEN(A1));2);LEN(A1))))
assuming value is in A1
Far from ideal, but with a shorter formula than the solutions offered so far:
=SUBSTITUTE(A1,".","_",3)
Catch is that formulae would then need to be converted to values, parsed with delimiter _ (being careful to ensure Column data format is Text) and surplus columns deleted.
When the string Amend.Clause_1.1.AddMCQ is in A1
=Find(".",A1,Find(".",A1)+1)
will give the position of the second decimal point, then you should be able to extract the decimal number.
The syntax is
FIND(find_text, within_text, [start_num])
I am putting a string into excel. The string is often only numeric digits but can have alpha characters or hypens etc.
When I don't set the number format or set it like this
(Where xlSheet(0) is Excel.Worksheet)
xlSheet(0).Columns("N:N").EntireColumn.Columns.NumberFormat = "#"
It outputs in scientific notation.
When I use this code:
xlSheet(0).Columns("N:N").EntireColumn.Columns.NumberFormat = "0"
It rounds up the number to the nearest 100,000 so that the last five digits are 0's when they shouldn't be.
Should be: 1539648751235678942
But is: 1539648751235600000
The cells that have a hyphen or a letter aren't affected and work fine.
Any help would be greatly appreciated.
EDIT:
I add the data like this:
I loop through and put in xlSheet(0).Cells(i, 14) = rs!value_number
Where rs is my ADODB.Recordset
EDIT2: Herbert Sitz got it by adding an apostrophe before the text! Thanks everyone.
I think problem is that the number you're trying to enter can't be accommodated exactly by Excel. Excel has limitations on what numbers it display/represent because of the way numbers are stored internally. In Excel's case numbers are limited to 15 digit precision (see http://office.microsoft.com/en-us/excel-help/excel-specifications-and-limits-HP010073849.aspx ), which is not enough to represent your number.
You can enter the number as a string ("152..42") and all digits will be displayed, but you won't be able to perform exact mathematical operations with it.
For numbers, Excel can only handle 15 significant digits.
If you want to store a number that is more than 15 digits long without losing data, you have to store the data as text.
Doing what you've been doing will resolve the issue:
You can do either of the following to add your numbers as text:
xlSheet(0).Cells(i, 14).Numberformat = "#"
xlSheet(0).Cells(i, 14) = rs!value_number
Or
xlSheet(0).Cells(i, 14) = "'" & rs!value_number