In Excel I have three columns, say A, B and C, all with the background format of hh:mm:ss and the 1904 date system, meaning that I can do simple arithmetic across the columns.
Cells in columns A and B will mostly be populated with times but can also be either blank or have text in them.
Using cells A1, B1 and C1 as an example I need a formula in C1 which says if both A1 and B1 have times within them then perform the sum A1 minus B1 into C1. So if A1 is 01:07:26 and B1 is 01:08:26 the resultant sum in C1 will be -00:01:00. If blank or text appears in A1 and/or B1 then the arithmetic function will not be performed.
I have been going round in circles with SUMIFS and have not managed to figure out a formula which will do the trick so if anyone could help me I would be very grateful.
I don't have Excel on this machine, but a more fruitful approach would
be something like:
=IF(AND(ISNUM(A1),ISNUM(A2)),A1-B1,"")
If you need more fine-grained checking for a time, see this post.
Related
any excel formula to subtract cells separated by comma (textjoin etc etc)
example:
A1 has this data (10/01/2021,20/03/2021)
A2 has this data (15/01/2021,26/03/2021)
I want to subtract A2-A1 which is (15/01/2021-10/01/2021,26/03/2021-20/03/2021)
output would be (5,6)
Note A1 and A2 might not have equal set of dates. A1 might have only two dates, A2 might have only two or four etc etc and vice-versa. Ideally first date of A2 should should be subtracted from first date of A1 and so on)
If your dates are always entered with this format, you can do it with this silly thing;
=CONCATENATE(LEFT(RIGHT($A$2,LEN($A$2)-1),10)-LEFT(RIGHT($A$1,LEN($A$1)-1),10),",",(RIGHT(LEFT($A$2,LEN($A$2)-1),10)-RIGHT(LEFT($A$1,LEN($A$1)-1),10)))
I had to change the date formatting to MM/DD/YYYY because my system is set to United States and it wasn't working the with DD/MM/YYYY.
But, VBA would probably be more reliable.
EDIT: Sorry missed the part where you said dates may not always have only two dates. You could do it but its just a long sting of garbage that it would just be better to work in VBA.
Good day!
Using Excel and would like to multiply a date by a value to create new a row with the same date
Example;
before
Column A
27-OCT-19
execution
Column A Column b
27-OCT-19 X 4
output
Column A
27-OCT-19
27-OCT-19
27-OCT-19
27-OCT-19
I've looked around and it seems that people use Visual Basic - However, I can't use Visual Basic due to permission issues on my network.
If your first date begins in cell A2 then enter this formula in cell B2:
=MID(REPT(TEXT(A2," dd-mmm-yy"),4),2,99)
Now copy the formula downward as far as you need.
Based on your revised question, the following should work.
With your reference date in cell A2 and your multiply value in cell B2 enter this formula in cell A3:
=IF((ROW()-ROW($A$2))<$B$2,$A$2,"")
Now copy the formula downward as far as you need.
If you have Excel O365 with the SEQUENCE function, you can use:
A3: =TRIM(MID(SUBSTITUTE(REPT(TEXT($A$2,"dd-mmm-yy "),B2)," ",REPT(" ",99)),IF(SEQUENCE(B2)=1,1,(SEQUENCE(B2)-1)*99),99))
and the results will SPILL down as far as required.
Master and Step Chart
Hello, I'm using A4-E4 as a "Master" code, and incrementally using A5-A8 to replace A4, B5-B8 to replace B4, etc etc first replacing one number of the "master", then two different numbers, etc until I have basically every combination. At some point the same number as the "master" is going to be generated. I have the numbers separated into groups of 16 on individually sheets for a total of 64 sheets. Obviously at some point the same number "43254" is going to generate on one of the sheets. Is there a way to search/highlight that number automatically upon generation? I've found that I can do conditional formatting to search for a specific cell, but not a range of cells. Like compare "A4-E4" to every set of five adjacent numbers in all the sheets, then highlight it. I have no idea if this is possible, but I'd appreciate it.
Select cells A4 through E4 and go to Format -> Conditional Formatting -> Manage. Apply style Good if Formula is:
CONCATENATE($A4;$B4;$C4;$D4;$E4)="43254"
So 43254 matches.
And 43253 does not match.
This is more complex than first appears. The following explanation may be difficult to understand if you do not have much experience with conditional formatting.
The formula gets evaluated 5 times, once for each of the cells.
Normally, rather than always indicating cell A4, Calc would interpret A4 as the currently evaluated cell (because we selected cells starting from A4). And B4 would indicate the cell to the right of the current cell that is evaulated. So for example, if such a conditional formatting formula were filled to cell D7, then A4 would actually indicate cell D7, and B4 would indicate cell E7.
However, our formula uses $A4 instead. The $ tells Calc that we always want column A even if the formatting is for column B or C et cetera.
One outcome of this is that the formula can be filled down or up but not left or right. If it is filled down one row for example, $A4 refers to column A but the current row, which would be cell A5.
I am trying to put together a conditional formula for an Excel spreadsheet. What I need is for the row to highlight when cells A2 and B2 are two different, but specific numbers. For example, I want the second row highlighted when the value in A2 is exactly 12345 and when the adjacent value in B2 is exactly 67890. I do not want the row highlighted if the value in A2 is anything other than 12345 and the value in B2 is anything other than 67890. There are about 3,500 rows of numbers, so I am trying to speed up the process. I will eventually have to do the opposite, and see when the value in A2 is 67890 and when the value in B2 is 12345.
In order to clear up any questions, I am looking at an Excel document tracking phone calls made over a long period of time, and I want to highlight the whole row when two different phone numbers are calling each other among all the other phone calls.
With conditional formatting, you can use formulas. Highlight a row (let's say row 2 to start), and in Conditional Formatting, under "Use a formula...", =and($b2<>$a2,$a2=12345,$b2=67890).
If you apply that to your whole range (a2:b100, let's say), if the cell in A and B are different, and then only if A and B are the numbers you want, will the row be highlighted.
edit: added absolute cell references. Also, see #Grade'Eh'Bacon's comment.
I have a spreadsheet with 4 columns : A, B, C, D.
I want to calculate the difference between A-B and C-D. So in cell E2 I enter the formula =A2-B2 , and get the result that I want, which is the difference between A-B.
Now I drag the formula in E2 to cell F2, expecting that Excel will "think" that now I want the difference between C-D. However, when I drag the formula from column E to column F I get =B2-C2 (you see, Excel assumes I want to use B2 again).
My question is: how can I make Excel “understand” that I want to use =C2-D2 after =A2-B2, and NOT =B2-C2?
This an abbreviated example. The original data-set has hundred of columns. Thanks for your help.
Enter Formula in E2
Drag the formula up till G2. Now G2 will have the formula which you want.
Delete Col F. Now Col G will move to Col F, which will have your required formula
There's no way in the UI that you get Excel to "think" that much - it'll only shift the references by one column if you drag it across. If deleting the columns in between is not an option, you need to rewrite you formula, e.g.:
=OFFSET(A1,0,COLUMN(L1)-COLUMN($L1))-OFFSET(B1,0,COLUMN(L1)-COLUMN($L1))
In this example, it is assumed that you start showing the difference in column L - of course you need to adjust according to your worksheet - but once done, you can drag the formula to the right as far as you need.
As your original data-set has hundreds of columns, you may want to use a non-volatile formula, eg:
=INDEX(A1:K1,1+COLUMN(L1)-COLUMN($L1))-INDEX(A1:K1,2+COLUMN(L1)-COLUMN($L1))
This will speed up calculations in the workbook. Depending on how big the data-set is and how many other formulas are in the workbook, the difference in speed could be enormous.
The same conditions apply as in Peter's example.