I have a formula, that extracts a number from a cell (like bla bla Pris: xxx.00):
MID(A3:A2000,FIND("Pris: ",A3:A2000)+6,FIND(".00",A3:A2000)-FIND("Pris: ",A3:A2000)-6)
The result is correctly xxx
But xxx can't be calculated on in other cells.
You can use the VALUE() function to convert a string into a number.
So it will look like
=VALUE( MID(A3:A2000,FIND("Pris: ",A3:A2000)+6,FIND(".00",A3:A2000)-FIND("Pris: ",A3:A2000)-6) )
try:
=INDEX(MID(A3:A2000, FIND("Pris: ",A3:A2000)+6,
FIND(".00", A3:A2000)-
FIND("Pris: ",A3:A2000)-6)*1)
or just:
=INDEX(REGEXEXTRACT(A3:A, "Pris: (\d+)\.")*1)
Related
I'm making a list for buying groceries in Google Sheets and have the following value in cell B4.
0.95 - Lemon Juice
2.49 - Pringle Chips
1.29 - Baby Carrots
9.50 - Chicken Kebab
What I'm trying to do is split using the dash character and combine the costs (0.95+2.49+1.29+9.50).
I've tried to use Index(SPLIT(B22,"-"), 7) and SPLIT(B22,"-") but I don't know how to use only numbers from the split string.
Does someone know how to do this? Here's a sample sheet.
Answer
The following formula should produce the result you desire:
=SUM(ARRAYFORMULA(VALUE(REGEXEXTRACT(SPLIT(B4,CHAR(10)),"(.*)-"))))
Explanation
The first thing to do is to split the entry in B4 into its component parts. This is done by using the =SPLIT function, which takes the text in B4 and returns a separate result every time it encounters a specific delimiter. In this case, that is =CHAR(10), the newline character.
Next, all non-number information needs to be removed. This is relatively easy in your sample data because the numbers always appear to the left of a dash. =REGEXEXTRACT uses a regular expression to only return the text to the left of the dash.
Before the numbers can be added together, however, they must be converted to be in a number format. The =VALUE function is used to convert each result from a text string containing a number to an actual number.
All of this is wrapped in an =ARRAYFORMULA so that =VALUE and =REGEXEXTRACT parse each returned value from =SPLIT, rather than just the first.
Finally, all results are added together using =SUM.
Functions used:
=CHAR
=SPLIT
=REGEXEXTRACT
=VALUE
=ARRAYFORMULA
=SUM
Firstly you can add , symbols start and ends of numbers with below code:
REGEXREPLACE(B4,"([0-9\.]+)",",$1,")
Then split it based of , sign.
SPLIT(A8, ",")
Try below formula (see your sheet)-
=SUM(ArrayFormula(--REGEXEXTRACT(SPLIT(B4,CHAR(10)),"-*\d*\.?\d+")))
I am in a pickle and need some help extracting portion of a string in a google sheet cell.
SM - Lead - LINE ITEM GOES HERE (ABC) - Jan $ 11.75 3,515.00 $ 41,301.25
I am looking to extract the amount after the second dollar ($) sign.
Thank you!
Assuming the second dollar sign is always at the end of the string, you can also try
=regexextract(A2, "[^$\s]+$")
Assuming that the spaces and the format will be the same, you can try the formula below:
=REGEXEXTRACT(A1,"\$ \S+ \S+ \$ (\S+)")
This resulted to:
I have some really big numbers with me in an excel. I need to concatenate double quote in both the end of each number.
Like I have number:
20150909110448800000000000 in A1
20150909105944800000000000 in B1
and 20150909110448700000000000 in C1
And i need the output like :
"20150909110448800000000000","20150909105944800000000000","20150909110448700000000000" in D1
I have tried changing the format of cell D1 by selecting Format Cell --> Number --> Custom --> 0 --> "OK"
Then Put the concatenate function in D1.
=CONCATENATE(CHAR(34),A1,CHAR(34),",",CHAR(34),B1,CHAR(34),",",CHAR(34),C1,CHAR(34))
But it is giving output as :
"2.01509091104488E+25","2.01509091059448E+25","2.01509091104487E+25"
Instead of what I expect.
Can you please provide the solution to get rid of this E+ in the output?
You can convert your numbers to text and then concat. As you output will be text if you add " ".
=CONCAT(CHAR(34),TEXT(A1,0),CHAR(34),TEXT(B1,0),CHAR(34))
i have the string price that has a value with a number in it. I have code that extracts the number, I need help to figure out how to have another string (pricechar) with only the "k" in it
price="1k"
--pricechar=...
pricenum=string.match(price,"%d+")
You can extract all non-numeric characters, similar to how you do it for numbers:
pricechar = string.match(price,"[^%d]+")
To get both values at the same time:
pricenum, pricechar = string.match(price,"(%d+)(.*)")
I have placed the following in cell A1:
"a lot of text marker: xxx some more text"
I would like to copy the xxx value into cell A2.
Any suggestions on how this could be done?
Thanks
=MID(A1, FIND("marker:",A1) + LEN("marker:"), 4)
I am assuming that the xxx (per your example) is 3 characters long and a space is present between "marker:" and "xxx".
Just my two cents. Find() is case sensitive so if the text in A1 is
"a lot of text Marker: xxx some more text"
Then Find will give you an error.
You can use Search() in lieu of FIND()
=MID(A1, SEARCH("marker: ",A1) + LEN("marker: "), 3)
Also depending upon your regional settings you might have to use ";" instead of ","
If you wanted a VBA solution, this worked for me using your sample input:
Function GetValue(rng As Excel.Range) As String
Dim tempValue As String
Dim arrValues() As String
' get value from source range
tempValue = rng.value
' split by ":" character
arrValues = Split(tempValue, ":")
' split by spaces and take the second array element
' because there is a space between ":" and "xxx"
GetXXXValue = Trim$(Split(arrValues(1), " ")(1))
End Function
To use, put this code into the sheet module (see Where do I paste the code that I want to use in my workbook for placement assistance) and then put the following into cell A2:
=GetValue(A1)