Can I do this without a marco? - excel

I have a data set that looks like this:
$40/5y 6m
$25/12y
$57/5y
$25/10y
$44/3y, $45.32/3y, $46.68/3y, $48.08/3y, $49.52/3y
$67/5y, $72/5y
$28/5y
I need to multiply the dollar amounts by their respective year and sum them if there is more than one. For example the first row would need to be 40*5.5 and the second to last row would need to be (67*5) + (72*5). I tried text to columns and a bunch of find and replace, but it was such a messy solution and didn't really work as planned. So, should I learn how to do macros or is this something that can be done with simple formulas?

See if this works:
1) Copy everything into Microsoft Word
2) Open "find and replace" and do the following replacements ("use wildcard characters" should be unchecked):
- replace (one space) with nothing
Then these have no spaces:
- replace $ with ^t
- replace / with ^t
- replace y, (with the comma) with ^t^t
- replace y with ^t
- replace m with nothing
Now paste this back in an Excel spreadsheet. You should have your data separated in cells like this:
(empty), dollars, years, months, (empty), dollars, years, months, (empty), dollars, years, months...
So then you could just make a partial calculation every 3 cells =dollars*(years+(months/12)) and then sum these partials into one total.
Would this help?

Related

Excel: Concatenating cells & text using IF statements

I'm trying to combine several cells of data. My problem is in placing spaces between data and, more importantly NOT putting a space when there's no data so I don't get double spaces. Here's a sample:
=TRIM(M12)&IF(N12<>M12;"-"&TRIM(N12);"")&" "&TRIM(G12)&" "&TRIM(H12)&IF(LEN(I12>0);" "&TRIM(I12)&" ")&TRIM(J12)
The data is start year (M), end year (N), make (G), model (H), body style (I), driveline (J).
For some the values in start year and end year are the same.
&IF(N12<>M12;"-"&TRIM(N12);"")
This works perfectly. If the end year is the same as the start year it does not add a - or space after.
For many rows there is no value in body style.
&IF(LEN(I12>0);" "&TRIM(I12)&" ")
This will print the body style if it's present but it always adds a double space if there is no value in body style.
When I change that reference to:
&IF(LEN(I12>0);"-"&TRIM(I12)&"+")
both the - and + print regardless of what's in I12
I've tried many variations. None work, some throw errors. Probably obviously, I do not know what I'm doing in Excel but I'm thinking there must be a better way of checking the cell I12? I tried >1 with no luck but I'm not sure what to check besides the length of the data within.
The TRIM function not only removes leading and trailing spaces, but also reduces any internal multiple space sequences to a single space. By wrapping the whole formula in TRIM(..) you can ignore the possibility of creating double spaces.
Regarding
When I change that reference to:
&IF(LEN(I12>0);"-"&TRIM(I12)&"+")
both the - and + print regardless of what's in I12
This suggests that I12 actually has one or more spaces. Fix that by using LEN(TRIM(I12))>0
Or better, just go ahead and concatenate I12 and let TRIM clean up the spaces.
Note: I'm assuming the IF(LEN(I12>0);"-"&TRIM(I12)&"+") version was just to test that bit of code, so haven't delt with adding - and +.
So, your whole formula can become
=TRIM(M17&IF(M17<>N17;"-"&TRIM(N17);"")&" "&G17&" "&H17&" "&I17&" "&J17)
If you have a version of Excel that supports TEXTJOIN then you can use
=TRIM(M16&IF(M16<>N16,"-"&TRIM(N16),"")&" "&TEXTJOIN(" ",TRUE,G16:J16))

How to I extract a number between 2 symbols on google sheets

I'd like the output to be 10 and 200.
You should also try
=ArrayFormula(IFERROR(REGEXEXTRACT(B2:B, ".* (\d+) /.*")*1))
Or omit the arrayformula and drag down
=IFERROR(REGEXEXTRACT(B2, ".* (\d+) /.*")*1)
Other suggested solution may work for the given example.
Think ahead though for a more concrete solution in situations like
column B
--------------------------------------------------------------------------
Medical Face Shield - Pack - 10 / Next Day Shipping
KN95 Protective Mask - Type B - Carton - 200 / Next Day Shipping
MM - 33 Face Shield - 555 / - Type B - Carton - 1000 / Next Day Shipping
Functions used:
REGEXEXTRACT
ArrayFormula
IFERROR
#Catherine, your image doesn't show the range where your raw data resides nor where you want the results. And you've only allowed us to see two examples. But based on those two examples, and supposing that your raw data were in B2:B, delete everything from A2:A (or use another empty column) and place the following formula in A2 (or parallel):
=ArrayFormula(IF(B2:B="",, REGEXEXTRACT(B2:B, "- ([0-9]+)")))
This reads (in plain English): "If any cell from B2 down is blank, don't put anything in the results column. If it's not blank, extract from whatever is in the current row in Column B any group of numbers that follows a dash-and-space combination."
Everything in quotes within the REGEXEXTRACT denotes what to look for, while what is in parentheses denotes the part of that to extract.
If you need to count or do math with the extracted portions, add a VALUE wrap to the REGEXEXTRACT like this:
=ArrayFormula(IF(B2:B="",, VALUE(REGEXEXTRACT(B2:B, "- ([0-9]+)"))))

excel CountIf or

Both options work fine as you can see in my picture of my spreadsheet in column R & Q where the counts are.
Most of my columns are in military time formats like 24:00 one of the column I am working on is the X column that I am trying to get added to this time count if possible I a Number column where the numbers start from 10,11,13 and so on. Long story short.
I need Numbers in column X # 10 ,11 to be in the count for count for column O as you can see in column Q & R I got it set up for my count and it works just fine but that’s without the special deal I need from column X where I only needs these numbers from 10,11, a few from # 13.
So, in a nut shell I just need it to say give me the column O times if there is a # 10,11,13 in column X
= COUNTIF($O$13:$O$1000,">=0:21")-COUNTIF($O$13:$O$1000,">0:30")
Connection time
Connection time
https://support.google.com/docs/answer/3093480 - similar functionality. You have 0:21 - 0:30.. What's that all about? Zeros? O21 or 0.21? etc. If it's meant to be time, you want to strip out that stuff, and add things up probably using decimals so 30 seconds is 0.5 min.. Or convert everything to seconds... Then you can convert back after.If it's minutes and you want the granularity split it into columns. LEFT(cell,FIND(":"),cell) , RIGHT(cell,len(cell)-find(":")). May be off by one either way so a +1,-1 may be needed... Then convert text to number VALUE(text). And countif does not allow strings for comparison. So quotes around last parameter are a "no no"! Only numbers..
Instead of
=COUNTIF($O$13:$O$1000,">=0:21")-COUNTIF($O$13:$O$1000,">0:30")
Try the following:
=COUNTIF($O$13:$O$1000,">="&Time(0,21,0))-COUNTIF($O$13:$O$1000,">"&time(0,30,0))

Extract number between brackets in Excel?

I've been searching up and down for an answer to this, but haven't found anything I can get to work. It may well be my lack of knowledge in the more "codey" aspects of Excel.
Anyway, this is my situation:
In C2-C17, I have some text set up like this:[2] Name of job.
The "[2]" indicates the hours we expect the assignment to take, the rest is the name of the assignment.
Now I need to calculate how many hours all this adds up to, so in B2-B17 (the numbers will change) I would like to extract the number between the brackets, in this case "2", so I can simply calculate and add them up.
How would I go about doing this? I've spent far too long at work by now, trying to find a solution that works for me.
Any help would be very much appreciated!
Use the formulas: MID(cell,start_num, length) and FIND(text,cell)
So, the formula is:
=MID(B3, FIND("[",B3)+1, FIND("]",B3) - FIND("[",B3) - 1)
Which means:
Extract the text from the cell B3, starting from the location of character "[" plus 1 in the same cell, and a total of chars calculates by: location of "]" - location of "[" minus one.
Copy to a new column, Find & Replace, Find what:
*[
Replace All. Find what:
]*
Replace All.
There is a function to work with substrings: "MID"
The C3 cell have formula. We assume that string will always start from [ and then will be number of hours (1 digit).
Than I just expand to other cells froc C3 to F3
You can add substitute function to work with two digit numbers.

retrieve part of the info in a cell in EXCEL

I vaguely remember that it is possible to parse the data in a cell and keep only part of the data after setting up certain conditions. But I can't remember what exact commands to use. Any help/suggestion?
For example, A1 contains the following info
0/1:47,45:92:99:1319,0,1320
Is there a way to pick up, say, 0/1 or 1319,0,1320 and remove the rest unchosen data?
I know I can do text-to-column and set the delimiter, followed by manually removing the "un-needed" data, but my EXCEL spreadsheet contains 100 columns X 500000 rows with each cell looking similar to the data above, so I am afraid EXCEL may crash before finishing the work. (have been trying with LEFT, LEN, RIGHT, MID, but none seems to work the way I had hoped)
Any suggestion will be greatly appreciated.
I think what you are looking for is combination of find and mid, but you'll have to work out exactly how you want to split your string:
A1 = 0/1:47,45:92:99:1319,0,1320 //your number
B1 = Find(“:“,A1) //location of first ":" symbol
C1 = LEN(A1) - B1 //character count to copy ( possibly requires +1 or -1 after B1.
=Left(A1,B1) //left of your symbol
=Mid(A1,B1+1,C1) //right size from your symbol (you can also replace C1 with better defined number to extract only 1 portion
//You can also nest the statements to save space, but usually at cost of processing quantity increase
This is the concept, you will probably need to do it in multiple cells to split a string as long as yours. For multiple splits you probably want to replicate this command to target the result of previous right/mid command.
That way, you will get cell result sequence like:
0/1:47,45:92:99:1319,0,1320; 47,45:92:99:1319,0,1320; 92:99:1319,0,1320; 99:1319,0,1320......
From each of those you can retrieve left side of the string up to ":" to get each portion of a string.
If you are working with a large table you probably want to look into VB scripting. To my knowledge there is no single excel command that can take 1 cell and split it into multiple ones.
Let me try to help you about this, I am not a professional so you may face some problems. First of all my solution contains 2 columns to be added to the source column as you can see below. However you can improve formulas with this principle.
Column B Formula:
=LEFT(A2,FIND(":",A2,1)-1)
Column C Formula:
=RIGHT(A2,LEN(A2)-FIND("|",SUBSTITUTE(A2,":","|",LEN(A2)-LEN(SUBSTITUTE(A2,":","")))))
Given you statement of having 100x columns I imagine in some instances you are needing to isolate characters in the middle of your string, thus Left and Right may not always work. However, where possible use them where you can.
Assuming your string is in cell F2: 0/1:47,45:92:99:1319,0,1320
=LEFT(F2,3)
This returns 0/1 which are the first 3 characters in the string counting from the left. Likewise, Right functions similarly:
=RIGHT(F2,4)
This returns 1320, returning the 4 characters starting from the right.
You can use a combination of Mid and Find to dynamically find characters or strings based off of defined characters. Here are a few examples of ways to dynamically isloate values in your string. Keep in mind the key to these examples is the nested Find formula, where the inner most Find is the first character to start at in the string.
1) Return 2 characters after the second : character
In cell F2 I need to isolate the "92":
=MID(F2,FIND(":",F2,FIND(":",F2)+1)+1,2)
The inner most Find locates the first : in the string (4 characters in). We add the +1 to move to the 5th character (moving beyond the first : so the second Find will not see it) and move to the next Find which starts looking for : again from that character. This second Find returns 10, as the second : is the 10th character in the string. The Mid formula takes over here. The formula is saying, Starting at the 10th character return the following 2 characters. Returning two characters is dictated by the 2 at the end of the formula (the last part of the Mid formula).
2) In this case I need to find the 2 characters after the 3rd : in the string. In this case "99":
=MID(F2,FIND(":",F2,FIND(":",F2,FIND(":",F2)+1)+1)+1,2)
You can see we have simply added one more nested Find to the formula in example 1.

Resources