How can I change text to number in Excel? - excel

Here is what I put in the cell
="A "&'2018-2019'!C34&" B"
and this is what I got
A 1256838 B
But I want it to display like this
A 1,256,838 B

Use TEXT to format the number.
="A "&TEXT('2018-2019'!C34, "#,##0")&" B"
In fact, if the prefix and suffix characters are static, they can be wrapped into the format mask.
=TEXT('2018-2019'!C34, "\A #,##0 \B")
The \ is an escape character. I'm pretty sure that A is not a reserved character in a format mask but B is used for the Buddhist calendar.

Related

Excel Formula To Replicate Text To Column Functionality

I would like a formula in excel that does what Text To Columns does.
For example the following string in A1
" text with a comma, stays in one column",," keep starting blank text",1,2,3,"123"
Would be split into multiple cells like this...
The following LET Function allows you to split the text into columns based on the splitter character (in this instance a comma).
It ignores commas that are between quotes (the Delim argument - which has double quotes in it).
It does this by ensuring there is an even number of quotes before the splitter character.
=LET(
NOTES,"Splits a string but also checks to see if the splitter is inside a delimiter. So will ignore a comma inside quotes.",
RawString,$A1,
Splitter,",",Note2,"This is the character to split the string by",
Delim,"""",Note4,"This is the text delimiter it looks odd but it's just a double quote - change to "" if you don't want text delimitation",
IgnoreBlanks,FALSE,
CleanTextDelims,TRUE,
TrimBlanks,FALSE,
SplitString,Splitter&RawString&Splitter,Note3,"Add the splitter to the start and the end to help create the array of split positions",
StringLength,LEN(SplitString),
Seq,SEQUENCE(1,StringLength),Note5,"Get a sequence from 1 to the length of the split string",
Note6,"The below does the bulk of the work. It works out if we are at an odd or even point in terms of count of text delimiters up to the point in the sequence we are processing.",
Note7,"if we are at an even point and we have a delimiter then make a note of the sequence otherwise put a blank.",
PosArray,IF(Seq=StringLength,Seq,IF(MOD(LEN(LEFT(SplitString,Seq))-LEN(SUBSTITUTE(LEFT(SplitString,Seq),Delim,"")),2)=0,IF(MID(SplitString,Seq,1)=Splitter,Seq,""),"")),
PosArrayClean,FILTER(PosArray,PosArray<>""),Note8,"Clean blanks",
StartArray,FILTER(PosArrayClean,PosArrayClean<>StringLength),
EndArray,FILTER(PosArrayClean,PosArrayClean<>1),
StringArray,MID(SplitString,StartArray+1,EndArray-StartArray-1),
StringArrayB,IF(IgnoreBlanks,FILTER(StringArray,StringArray<>""),StringArray),
StringArrayC,IF(CleanTextDelims,IF(LEFT(StringArrayB,1)=Delim,MID(StringArrayB,2,IF(RIGHT(StringArrayB,1)=Delim,LEN(StringArrayB)-2,LEN(StringArrayB))),StringArrayB),StringArrayB),
IFERROR(IF(TrimBlanks,TRIM(StringArrayC),StringArrayC),"")
)
Breaking down each step in the LET formula:
Supply the raw string (from cell A1 in this case)
Set the splitter character - in this case a comma
Set the text delimiter - in this case double quotes (looks odd because it has to be as double double quotes - Delim,"""" )
IgnoreBlanks is an option to exclude blank cells in the output
CleanTextDelims will clean the TextDelimiter (Double quotes) from the start and end of the resultant string
Create a SplitString variable with the split character at the front and back.
Get the length of the string for ease of use
Get a sequence from 1 to the length of the string.
Get an array of the position of characters that are splitters with an even number of Text Delimiters to the left of that position in the string the posArray (splitter position array).
Clean the blanks to get the posArrayClean
Create a start and end array (start array ignores the last and end array ignores the first item in the PosArrayClean)
Get the array of strings/cells to output.
If the IgnoreBlanks is used then igore blank cells
If the CleanTextDelims option is set then strip off the Text Delim (double quotes) from the start and end of the resultant string.
If the TrimBlanks option is set then trim blank spaces off the start and end of the resulting strings.
Hopefully the notes explain clearly how this works and make it easy to modify.
If you want create a named Lambda to use you can use the following code to paste into the formula of a named range called SplitStringDelim (you can name it what you like of course). NB You can't have the line separators in this and I stripped the notes out of it.
=LAMBDA(StringRaw,SplitChar,DelimChar,IgnoreBlank,CleanTextDelim,TrimBlank, LET( RawString,StringRaw, Splitter,SplitChar, Delim,DelimChar, IgnoreBlanks,IgnoreBlank, CleanTextDelims,CleanTextDelim, TrimBlanks,TrimBlank, SplitString,Splitter&RawString&Splitter, StringLength,LEN(SplitString), Seq,SEQUENCE(1,StringLength), PosArray,IF(Seq=StringLength,Seq,IF(MOD(LEN(LEFT(SplitString,Seq))-LEN(SUBSTITUTE(LEFT(SplitString,Seq),Delim,"")),2)=0,IF(MID(SplitString,Seq,1)=Splitter,Seq,""),"")), PosArrayClean,FILTER(PosArray,PosArray<>""),Note8,"Clean blanks", StartArray,FILTER(PosArrayClean,PosArrayClean<>StringLength), EndArray,FILTER(PosArrayClean,PosArrayClean<>1), StringArray,MID(SplitString,StartArray+1,EndArray-StartArray-1), StringArrayB,IF(IgnoreBlanks,FILTER(StringArray,StringArray<>""),StringArray), StringArrayC,IF(CleanTextDelims,IF(LEFT(StringArrayB,1)=Delim,MID(StringArrayB,2,IF(RIGHT(StringArrayB,1)=Delim,LEN(StringArrayB)-2,LEN(StringArrayB))),StringArrayB),StringArrayB), IFERROR(IF(TrimBlanks,TRIM(StringArrayC),StringArrayC),"")))

Is there a way to add leading/trailing spaces to item in concatenate function?

I am trying to bring together several cells and they have a specific length so if I have
A1 needs to be 5 chars and the value is 'cat'
B1 needs to be 6 chars and the value is 'dog'
Concatenated it would be:
[space space]cat[space space space]dog
or
" cat dog"
I'm having trouble finding a function or set of functions that allows this, most want to trim out leading or trailing spaces.
Yes:
=CONCATENATE(RIGHT(REPT(" ",5)&A1,5),RIGHT(REPT(" ",6)&A2,6))
or as #BigBen stated use & instead of Concatenate:
=RIGHT(REPT(" ",5)&A1,5)&RIGHT(REPT(" ",6)&A2,6)

MS Excel Forumla assistance

I have a cell I need to split into 2 cells.
Data Sample: Note: All Cells are formatted as TEXT
"3851v61_18.005_ Have the anchors for all suspended scaffolding system suspension lines and separate vertical lifelines been verified? "
Data Sample 2: Parent_ID
Steps:
Need to check to see if the cell value starts with number.
Also, If it contains a special character ("_") if may have more than 1.
Display cell #1 = just the ID number containing the underscore(s).
Display cell #2 - Just the text right of the underscore. However, if the original cell only starts with Alpha characters then display the actual value. ie. Parent_Id
Strip off any erroneous underscores left hanging.
Expected results:
Cell #:
"3851v61_18.005" (ID Number portion of the Text)
"Have the anchors for all suspended scaffolding system suspension lines and separate vertical lifelines been verified?
This is what I have so far: (If it does not start with a number, then return the value of the cell, else continue with the equation)
`=`IF(NUMBERVALUE(LEFT(C321,1))>=1,IFERROR(LEFT(C321, FIND("_",C321)-1), C321),FALSE)`
=IFERROR(RIGHT(C321,LEN(C321)-FIND("_",C321)), C321)`
If the Underscore count is more than one need to include it in the entire number and strip off the text after the last underscore in Cell 1. At the same for the right of the Underscore to display the text after underscore in Cell 2.
Thank you for any assistances offered.
I think I understand but am not 100% sure.
Try something like the below to get the full string (if it starts with something that isn't a number) or the string up to the last underscore (if it does start with a number):
=IF(NOT(ISNUMBER(NUMBERVALUE(LEFT($D1,1)))), $D1,
LEFT($D1, FIND("!!!", SUBSTITUTE($D1, "_", "!!!",
LEN($D1)-LEN(SUBSTITUTE($D1, "_", ""))))-1))
Then in a similar fashion try something like the below to get the full string (if it starts with something that isn't a number) or the string to right of the last underscore (if it does start with a number):
=IF(NOT(ISNUMBER(NUMBERVALUE(LEFT($D1,1)))), $D1,
RIGHT($D1, LEN($D1)-FIND("!!!", SUBSTITUTE($D1, "_", "!!!",
LEN($D1)-LEN(SUBSTITUTE($D1, "_", ""))))))
For example:

Convert value of money

I can't seem to find this or I am not searching for the correct term. I am simply trying to change money to long string. The data being pulled to D cell has it as $7.5K for example. I would like to remove the dollar symbol and write the decimal to long form so change $7.5K to 7500.
A few notes:
-ALL the data is above $1K so nothing will be below that amount.
-money has no ONEs or TENs value so these are always 00.
Not sure if I can automate this or make it easier to convert these values using the Find/Replace.
If the true /underlying value is a number, simply reformat as Number with no decimal places. If a text string either:
Replace K by *1000 and then $ by = and format to suit
or, as suggested by #Ken White, apply a formula such as:
=1000*SUBSTITUTE(SUBSTITUTE(A1,"$",""),"K","")
again with suitable formatting.

How to Find a word with spaces in livecode

How to find a word with space (eg: i want to find a word "X1 X2 X3"). I am using the following code
put the text of field "f4" into xx
find xx in field "f1"
In LiveCode, the space character delimits words -- a single word doesn't contain spaces. If there's only one instance of the string of characters you're searching for, you could use the offset function:
put "X1 X2 X3" into theString
put the text of fld "f4" into temp
put offset(theString,temp) into theNum
The variable theNum will contain the number of characters before the first character of the string, or will contain 0 if the string is not found in the field's text.

Resources