I'm trying to convert time to numbers in excel. I am using this formula:
=HOUR(A2) + MINUTE(A2) / 60 + SECOND(A2) / 3600
And it works well, but I have to convert a column with around 65.000 of dates.
How do I do that in an elegant and time saving way?
So assuming that your formula does what you want it to do, you just have to double click on the lower-right part on the cell with your first formula. So if your data are in the range A2:A65000, write your formula on cell B2, and double click on its lower-right part.
See the pic below:
Assume you mean time rather than date.
Try
=A2*24
Format as general
To apply to a large range you can put 24 into a spare cell, copy it, select range you want to convert to number and paste special... Then select multiply and okay.
Related
I am trying to clean some data with this format:
A1 B1 C1
"0,1,0,E,1" "0,0,0,E" "0,1,1,1,2,E"
To obtain the information, I will need to sum up each cell individually, and then calculate the sum over a row.
So far, I have replaced all of the "E"s (for empty) with no data, which removed the E's, and I have replaced all of the commas with "+" signs to add the numbers in the cell. To run the formula of each cell, I will need to now place an "=" in front of each text string, however, if I copy it in with something like "="="&A1" the formula will not run because excel is reading the = as a letter or symbol and not an operator. Do you know of a way to fix this problem?
Thank you so much!
I think this will work for your version ...
=SUM(FILTERXML("<d><c>" & SUBSTITUTE(A1,",","</c><c>") & "</c></d>","//c"))
That's applied like below ...
... there's always someone smarter than me but that seems to work.
It’s not an in place replacement but it keeps your source data intact and provides a nice reconciliation point.
Using a separate sheet for each column of values, given data in cell A1 of
0,0,0,1,0,1,1,E,1,0
In C1, enter the formula
=IFERROR(MID(SUBSTITUTE(SUBSTITUTE($E$14,",",""),"E",""),COLUMN()-2,1)*1, "")
and drag the fill handle to to the right for as many cells as the longest number of data points you have.
Enter your SUM()formula in B1 (you can use the shortcut ALT + =).
Have you tried something like this, please refer the image, where its showing as per your required output, three alternative formulas
1.) Formula used in cell B2
=SUMPRODUCT(IFERROR(--MID($A2,ROW(INDIRECT("1:"&LEN($A2))),1),0))
2.) Formula used in cell D2
=SUMPRODUCT(IFERROR(--MID($C2,SEQUENCE(LEN($C2)),1),0))
The 2nd formula is applicable to Excel 2021 & O365 Users only
3.) Formula used in cell F2
=SUM(IFERROR(--MID($E2,ROW($1:$1000),1),0))
This is an array formula, so requires to press CTRL SHIFT ENTER !
Here is an update, the last formulas, which i have shared, shall work only when the digits are less than 10, however the present formula, shall work for all number of digits,
Formula used in cell B17
=SUMPRODUCT(IFERROR(--MID(SUBSTITUTE($A17,",",REPT(" ",100)),COLUMN(A1:Z1)*99-98,100),0))
Please adjust your range accordingly as per your data.
I have a schedule for work that lists employees shifts as durations, i.e. 11-7, 1030-6, etc. within a single cell. If these were single times like 6, 1130, etc, I could convert to time format easily, but how can I make these cells display the shift start and end time in time format?
The goal is to have excel use these times to sort and filter the corresponding employees on another sheet according to their scheduled shift. Is there a way to display "hh:mm-hh:mm" to represent a shift in one cell?
This is possible using formulas, but you have to be specific about formats and testing the entries.
The primary piece of the formula to understand is how to separate the time "values" on either side of the "-". This solution assumes that a dash ("-") will ALWAYS be present in the cell. For the shift entry "2-11" (assume this is in cell A2), you can use a combination of FIND, LEFT, and RIGHT to separate all the characters on either side of the "-" using these formulas
Cell A2 contains "2-11"
LEFT(A2,FIND("-",A2)-1 returns "2"
RIGHT(A2,LEN(A2)-FIND("-",A2)) returns "11"
IMPORTANT: these formulas now become "the time value" and will be repeated inside a larger formula.
From here on out, it's a matter of reformatting the string into a time-formatted string by adding a colon ":" at the appropriate place in the string in order to create an Excel time value.
Helper columns are used to get all the values cleanly, as shown in this example:
Formula in B2: =IF(LEN(LEFT(A2,FIND("-",A2)-1))<=2,TIMEVALUE(LEFT(A2,FIND("-",A2)-1)&":00"),TIMEVALUE(LEFT(A2,FIND("-",A2)-3)&":"&RIGHT(LEFT(A2,FIND("-",A2)-1),2)))
Formula in C2:
=TIMEVALUE(IF(LEN(RIGHT(A2,LEN(A2)-FIND("-",A2)))<=2,RIGHT(A2,LEN(A2)-FIND("-",A2))&":00",LEFT(RIGHT(A2,LEN(A2)-FIND("-",A2)),LEN(RIGHT(A2,LEN(A2)-FIND("-",A2)))-2)&":"&RIGHT(RIGHT(A2,LEN(A2)-FIND("-",A2)),2)))
Formula in D2: =IF(C2>B2,C2,C2+TIME(12,0,0))
Formula in E2: =(D2-B2)*24
Formula in F2: =TEXT(B2,"hh:mm")&" - "&TEXT(D2,"hh:mm")
I need to convert this data dd/mmm - 31.mar (March) to this format 31/03 - dd/mm using excel formula
A bit of googling would have solved your issue here.
Select cell (or range of cells).
Right click with mouse
Format Cells
Custom
Change Type: dd/mmm to dd/mm
=text([CellWithDate],"dd/mm")
is the formula you want, I think.
#Valeria:
Can't be sure I understood your problem and/or the type of solution you're looking for.
I assume you have a date in , say, cell A1 and that cell is showing the date in "dd-mmm" format.
I also assume you want that date to be shown in another cell (different from A1) in "dd/mm" format BUT without previously setting that target cell format to "dd/mm".
In case I'm right, the formula you should put in the target cell shouldo look like:
=DAY(A1) & IF(MONTH(A1)<10;"/0";"/") & MONTH((A1))
This way, if cell A1 holds "31-aug", you're getting "31/08" wherever you put that formula.
The value Excel actually stores in the cell is just its date+time serial number (whatever you're seeing is a very different question). DAY() and MONTH() do work on that value to generate day of the month and month of the year after that serial number.
Hope this helps.
I have one cell containing several lines, including numbers inside brackets, which I want to sum-up with a single Excel formula (no VBA).
The following approach already works for single bracket:
https://exceljet.net/formula/extract-text-between-parentheses
But I need extended approach... here an example for the content of one single Excel cell to which I search for an formula, which should result in sum of "8":
The task requires following effort (incl. documentation)
- create plan (2h)
- execute test (14h)
- write report (draft) (2h)
Possible approach: The formula should search for all numbers inside the mask <"(" x "h)">, where x must be summed-up.
UPDATE: The formula should also work with numbers >=10.
UPDATE2: It should also work in case there are other comments in brackets, also after presence of first (xh) number. See "(draft)" in example, last row.
Borrow the formula from this post #6 (https://www.mrexcel.com/forum/excel-questions/362184-extracting-multiple-numbers-string.html) and modified to fit your need (single cell formula). Assuming you are going to enter the formula in cell B1:
{=SUM(VALUE(MID(0&A1,LARGE(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))*ROW(INDIRECT("1:"&LEN(A1))),ROW(INDIRECT("1:"&LEN(A1))))+1,1)))}
Basically this is to assign each character with its index and then get the numeric value to sum up. Please note this is an array formula. Please click Ctrl + Shift + Enter together.
REVISED:
Here is the array formula (click Ctrl + Shift + Enter together) to extract two-digit numbers:
{=SUMPRODUCT(IFERROR(0+("0"&TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(MID(A1,SEARCH("h)",A1)-4,LEN(A1))),"h",""),")","("),"(",REPT(" ",1000)),ROW(INDIRECT("1:20"))*2*1000-999,1000))),0))}
What this does is to massage the text first by removing unnecessary content, remove h wording and convert ) to 999 blanks. Then you can extract numbers and add up. IFERROR will made the anything not numbers to 0. Hope this can solve your problem.
I appreciate that this is not in any way elegant, however it is working. I do not have time to run through the logic here right now (might edit it in later though) but essentially it is a load of search index logic.
I have Used 5 columns for each formula which assumes a maximum of 5 values but you can adjust this as needed by dragging the formula over more columns as it will begin looking for the next "(?h)" after the previous column's found value.
Red cell formula: =SEARCH("(?h)",$A1)&" - "&SEARCH("h)",$A1)
Orange cell formula: =SEARCH("(?h)",$A1,MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)+1))*1)&" - "&SEARCH("h)",$A1,MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)+1))+1)
Yellow cell formula: =MID($A1,LEFT(B1,SEARCH(" - ",B1))+1,((MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)))*1)-(LEFT(B1,SEARCH(" - ",B1))*1))-1)*1
Green cell formula: =SUMIF(G1:K1,">="&0)
how do I point to a cell when i calculate the number of the cell any time diffrently?
exemple:
='sheet1'!$F(C4+8)
In case that in C4 there is "2" then excel will read it as
='sheet1'!$F10
OR
='sheet1'!$F(Y9*8+X4:E1)
and in case of Y9=2 X4=32 E1=16
THEN excel will execute:
='sheet1'!$F18
I'd prefer to use INDEX rather than INDIRECT, i.e.
=INDEX(sheet1!$F:$F,C4+8)
You can replace C4+8 with any calculation that returns a row number
That has two advantages over INDIRECT - it isn't "volatile" and because the range isn't text it can adjust if you want to delete columns or copy across etc.
You will have to use INDIRECT():
=INDIRECT("'sheet1'!$F"&C4+8)
INDIRECT takes a text and converts it to a range. You can put formulas and other calculations inside.