Can anyone reproduce the error I get in Excel when rounding up by ten? - excel

I want to round up the minutes of my worktime in ten-steps (e.g 12 -> 20) in MS Excel.
I know the formula for doing so in Excel is (in German): =AUFRUNDEN(NUMBER;-1)
But problematically Excel sometimes does 10 -> 10 and othertimes 10 -> 20.

Thanks for sharing file. I was able to give an answer because of it :)
Is not an error. That annoying 10 is really 10,0000000000001. Yes, with 13 decimals, but you are using ROUNDUP so it gets rounded up to 20.
If I change format in that column to show a lot of decimals, you will get this:
So is not a whole number, and that tiny part (13 decimals!!!) makes Excel to round up to 20 instead of 10.
Easy way would be making sure the value stored in the cell is an integer, with a normal round. In column G your formula is:
=IF(F2;(F2-E2)*1440;D2*60)
Replace it with:
=ROUND(IF(F2;(F2-E2)*1440;D2*60);0)
And now it works as you want:
Hope you can adapt this to your needs.

Related

How to multiply in Excel using a fraction

I am looking to multiply a fraction (Betting Odd) by a whole number (Currency amount) for a betting spreadsheet I am creating for friends, and cannot find the answer anywhere in excel 2016.
Example: 22/1 x £5.00
Looking for the formula to multiply the £5 by 21 but also needs to add the stake (£5) back on, to return the proper answer of £110 return.
You should be able to get the correct answer by putting:
=(5)*(21)+(5) [I tested it in Excel to be sure]
and if these amount are cells you can just replace the numbers within the parenthesis with links to the cells.
Excel should be able to work out any fraction and multiplication by using / and *
Try working with the odds as text:
=A1*VALUE(LEFT(A2,FIND("/",A2)-1))/VALUE(RIGHT(A2,LEN(A2)-FIND("/",A2)))

How to Sum only hours using Sumif() from excel

I am Calculating Over Time of the employees in time format cell using Microsoft Excel 2007. In my result, its calculated as hh and mm. But I want only Hours and ignore Min.
Eg : I have to get this result of SANIA SARWER 0.18 as 0.0
See the screenshot below.
=SUMPRODUCT(Int(24*$B:$B),--($A:$A=D2))
How does it work?
Well, SUMPRODUCT will go through each item and multiply them together (So SUMPRODUCT(A1:A3,B1:B3) is the same as =(A1*B1)+(A2*B2)+(A3*B3)) - now, let's looks at each of the columns we're multiplying.
INT(24*$B:$B) is just Days, converted to Hours, and trim off the decimal part (minutes/seconds) - fairly simple.
--($A:$A=D2) first checks if the value in column A is the same as in D2 and gives TRUE or FALSE. The -- then converts this into 1 or 0, which we multiply by the hours before adding them all up.
Easiest way would be to Round Down the data using ROUND function, and then use SUM function to add the rounding data up.
You can find a simple example below.

Excel date Format issue - String

I have date format in the following manner in the excel which is in string format:
Apr 1, 2016 12:37:06 PM
Apr 2, 2016 12:00:00 AM
Apr 1, 2016 9:50:22 AM
Apr 1, 2016 12:09:38 PM
Apr 1, 2016 6:53:03 PM
Apr 1, 2016 1:02:10 PM
I have tried converting it from general to date however excel still does not recognize it as date format. Need your advise as what can I try more to solve this.
Thanks in adavance !!
try =DATEVALUE("date string").
hope this helps
here is how it works
if still didn't work, then it has to do with windows date time setting.
Open Region and Language setting from Control Panel. Change the Long Date format to "MMMM dd,yyyy". Because this is the format your date string is formatted. You have to do this to get DATEVALUE() in excel to work. Now go back to your formula and see if it works.
After that, copy paste the formulas as value. Then you can change back to your preferred long date format again (or just leave it).
Couple of options for you:
Option 1
Text to Columns built in excel feature
Select all Dates for starters. They need to be in one column. On the Data ribbon, select Text to Columns. Light green back ground in the image above.
On the ensuing window that pops up select Fixed Width. Then select Next.
Adjust the columns so you get either a single column or the date in one column with the time in the other. Then select NEXT.
In the bottom preview window select the first column. Then up top select the Date radio button and from the pull down select MDY format. when ready click on FINISH button
Option 2
Formulas
Ripping out the text from the string and rebuilding the date using some ugly long formulas. So we are going to do this in parts so you can see how the big ugly gets made. When we are done we will copy the smaller formulas into one formula which will be big ugly and hard to read.
One of the annoying thing is you have the month as an abbreviation. Somewhere off to the side you will need to build a table and put all the abbreviations in one column and the corresponding month number in the column to the right. There may be other ways to do this but this is what I am going with for now.
(AA) | (AB)
Jan | 1
Feb | 2
Mar | 3
Apr | 4
May | 5
Jun | 6
Jul | 7
Aug | 8
Sep | 9
Oct | 10
Nov | 11
Dec | 12
So we can either work from biggest (Year) to smallest (seconds) or from left to right. lets tackle this starting from the left.
First thing first we need to pull the month out. Thankfully its on the LEFT side and we know its only 3 characters long. So we can go straight to the excel formula and hard code this in. And alternative approach would be to find the space. So first formula to find month is
=Left(A1,3)
Since we are going to need to know the number of that month we can convert it with a VLOOKUP function (INDEX/MATCH is another option). Lets put this in column F for now.
=VLOOKUP(Left(A1,3),$AA$1:$AB$12,2,0)
That should return the number 3 for us. you will have to adjust the AA1:AB12 to suit where you put the table.
Next we are going to pull the day. We know its 1 or two characters to the left of the first comma. We will use the FIND to determine where that is since it is not in a fixed position.
=FIND(",",A1)
So we know the date will start either 1 or 2 characters to the left. No harm in taking two as it will be a space or a number. So now lets use that knowledge with the MID formula and place the following in column G for now:
=--MID(A1,FIND(",",A1)-2,2)
the -- changed the text to a number (they are not actually needed in this case). So the next one is a little trickier but still doable. We need to find the Year. wouldn't you know it, its a fixed 4 characters long and starts just after that same first coma. So lets reuse our previous formula but tweak it a little and put the following in column H for now:
=--MID(A1,FIND(",",A1)+2,4)
Well now that we have our Month, Day and Year as numbers we can build our date using the DATE formula which we can drop in say column I:
=DATE(H1,F1,G1)
now if you thing you are ready to get started on the big an ugly we can substitute each of our previous equation into our date equation so its all done in one cell. That big formula is going to look as follows:
=DATE(MID($A1,FIND(",",$A1)+2,4),VLOOKUP(LEFT($A1,3),$AA$1:$AB$12,2,0),MID($A1,FIND(",",$A1)-2,2))
Now when I say all in one cell, I should add the caveat that you do need that helper information of the list of months...though there is a way around that too. So that takes care of the date process. now to do the time is very very similar.
We have two options The first option may not work for you since the datevalue formula did not work for you.
Option A - TimeValue
The nice thing about your time set up, is that the time is either 10 or 11 characters long from start to finish and if we take all 11 when its really only 10 we again are just snagging a space. So lets grab the RIGHT time and place this formula in the K column:
=TIMEVALUE(RIGHT($A1,11))
Now if that option does not work for you then we break it down the same way we did for the date.
Option B - Stripping Time
So lets look at patterns to see what we can figure out...that first ":" looks like a great identifier so lets find it the same way we did up for the date. Let build our time formula in column N:
=FIND(":",A1)
Let sub that straight into the MID formula to pull the hour
=MID($A1,FIND(":",$A1)-2,2)
And in Column O we will do the same for minutes and again with a bit of tweaking
=MID($A1,FIND(":",$A1)+1,2)
And since we know that the minutes keep a leading zero for single digit minutes we also know exactly where seconds are going to start. Lets put this formula in column P:
=MID($A1,FIND(":",$A1)+4,2)
So you might be wondering what to do about the AM/PM Lets grab that and put that in column Q
=RIGHT($A1,2)
So now that we have all that information what are we going to do to build the time. Well first things first is you need to know that Excel like 24 hour clocks. However it really saves it time as a decimal of a day. So 12 noon is actually stored as 0.5 or half a day. Another important thing to know is that the official supported time range for Excel is 00:00 to 23:59. There is no 24:00. now having said that 24 as an hour makes VBA crash unless you specifically deal with it in some special code. You can however get away with supplying 24 as an hour in excel formulas and get away with it sometimes. ok enough with the time lesson let build this final formula in column R:
=TIME(N1+IF(AND(Q1="PM",N1<>"12"),12,IF(AND(Q1="AM",N1="12"),-12,0)),O1,P1)
You will note there is an IF formula in there that deal with the AM PM as well as the special case of the 12 hour. The 12 is in quotes because N1 is a string and I had not converted it to a number.
now for the uglyness of back substituting our formula so it all in one cell.
=TIME(MID($A1,FIND(":",$A1)-2,2)+IF(AND(RIGHT($A1,2)="PM",MID($A1,FIND(":",$A1)-2,2)<>"12"),12,IF(AND(RIGHT($A1,2)="AM",MID($A1,FIND(":",$A1)-2,2)="12"),-12,0)),MID($A1,FIND(":",$A1)+1,2),MID($A1,FIND(":",$A1)+4,2))
And yeah that is so easy to read! I asked if you needed this in one column or two. Well you have the full formula for the date on its on and the full formula for time on its on. So if you need them together here is an interesting tid bit of information. Since Time is stored as decimal days, that means everything to the right of the decimal is time. It also means that everything to the left (or the integer portion) are days. So to have date time in one column, you just need to add the two formulas together...or as I refer to it as, the really big ugly equation...or at least one of the many that fall into that category:
=DATE(MID($A1,FIND(",",$A1)+2,4),VLOOKUP(LEFT($A1,3),$AA$1:$AB$12,2,0),MID($A1,FIND(",",$A1)-2,2))+TIMEVALUE(RIGHT($A1,11))
or if time value did not work for you
=DATE(MID($A1,FIND(",",$A1)+2,4),VLOOKUP(LEFT($A1,3),$AA$1:$AB$12,2,0),MID($A1,FIND(",",$A1)-2,2))+TIME(MID($A1,FIND(":",$A1)-2,2)+IF(AND(RIGHT($A1,2)="PM",MID($A1,FIND(":",$A1)-2,2)<>"12"),12,IF(AND(RIGHT($A1,2)="AM",MID($A1,FIND(":",$A1)-2,2)="12"),-12,0)),MID($A1,FIND(":",$A1)+1,2),MID($A1,FIND(":",$A1)+4,2))
Now this is just one solution on how to break it down with formulas. There are other options or route I could have gone at a couple of steps, but it should work for you regardless of what your system settings are. Here is a screen capture of the results on my system. note I hid empty columns that were not in use in order to make the image narrower. Column T has custom formatting of
mmm, d, yyyy h:mm:ss AM/PM
applied to it.
Option 3
VBA
I am sure someone will supply at some point. And look it happened before I could get to that stage! I don't know why 8)
As for the VBA solution, you can open VBA editor, add a new module and paste this code:
Function STRTODATE(ByVal dcell As Range)
Dim datecon As Date
datecon = dcell
STRTODATE = datecon
End Function
then you can use STRTODATE as a formula. Only really helpful, if it's one off. If it's something you'd do regularly on different files, then it can be annoying to paste this code to every workbook.

Excel roundings not summing properly

I have a excel sheet with a few formulas like this:
A1,A2,A3= 0.13,1.25,2.21
A4: =(A1*A2) =0.16 ( 2 decimal points)
A5: =(A2*A3) =2.76 ( 2 decimal points)
A6: =SUM(A4;A5) =2.93 ( 2 decimal points )
And i want to show 0.16+2.76=2.92
well, there's my problem in bold. i want to add the values from the cells, not the formuls result. How can i do that ? Thank you
Presumably you're working with money which is why you need this.
One way to resolve this is to use =ROUND(A1*A2, 2) etc. and base your subsequent calculations from that.
Do be aware though that you will still occasionally get spurious results due to Excel using a 64 bit IEEE754 floating point double to represent numbers. (Although it does have some extremely clever circumvention techniques - see how it evaluates 1/3 + 1/3 + 1/3 - it will not resolve every possible oddity). If you're building an accounting-style sheet you are best off working in pence, and dividing the final result.
Round the values before you sum, ie:
=ROUND(A1*A2,2)
=ROUND(A2*A3,2)
You could wrap your formulas with the ROUND function:
=ROUND(A1*A2,2)
This will give you 0.16 as opposed to 0.163. Do this for each of your calculations and you'll only be calculating everything to two decimal places. Although I'm not sure why you'd want to do that.

Converting TEXT that represents NEGATIVE TIME value to a number or time value for adding (Excel)

I've got a spreadsheet (Office 2007 version of Excel) full of text entries that are negative time values, example "-0:07" as in an employee took 7 mins less to complete a job than expected. I need to perform mathematical calculations on these entries and am looking for a more elegant formula/method than I've come up with so far.
I know about 1904 date system and * or / by 24 to convert back and forth, the problem is getting a formula that will recognize the text entry as a negative time value.
I've tried value(), *1, which both work on the text fields if the number is positive, but the "-" seems to mess those up. Even paste-special/add fails to recognize these as numbers.
Here's what I came up with that gets the job done, but it's just so ugly to me:
=IF(LEFT(E5,1)="-",((VALUE(RIGHT(E5,LEN(E5)-1)))*-1.0),VALUE(E5))
Obviously my text entry is in cell E5 in this example.
This works, so I'm not desperate for a solution, but for educational purposes (and smaller code) I'd like to know if there's a better way to this. Does anyone have a suggestion for something shorter, easier?
Thanks.
P.S. - an interesting tidbit here, I use Excel at work, but not at home, so I uploaded a sample spreadsheet to Google Docs, and it actually handles the Value() command on those entries properly. Weird, huh?
Thanks again for any suggestions.
Excel doesn't handle time spans in cells. It only deals with time. When you do "00:07" it is then converted to 0.0048611 which is the same as Jan 1st 1900 12.07 am. So if you did 2 minutes minus 7 minutes it would give at best 11.55pm.
The way you do it is the only way.

Resources