Define List that Changes - excel

I have a list of time records that have 1 digit, 1 decimal, 2 digits, and an "hrs" description.
I'm looking to only get the first 4 characters of my list. But my list isn't constant so I can't write a VBA code to backspace records from A2:A100 (example range).
I need help defining my list (because the range of records changes) and then keystroking three backspaces for every value in my list. The reason I use three backspaces is because I can use a color scale on my new list that is now stored as a Number.
Below is a snippet of what I'm working with:
Original List New List (I will use a color scale)
1.96 hrs 1.96
1.73 hrs 1.73
0.00 hrs 0.00
1.90 hrs 1.90
I will also consider simply being able to use a color scale on my original list. My only guess in achieving this would be to format the values on my original list as Numbers. However, I've tried changing the formatting but I still can't use a color scale.
Any help would be greatly appreciated!

You shouldn't need VBA. You can just use built-in formulas.
First four characters, converted to value:
=VALUE(LEFT(A2, 4))
Replace " hrs", convert to value:
=VALUE(SUBSTITUTE(A2, " hrs"))
There are lots of other ways to do it.

Related

Subtract next number in sequence from the one before excel

I want to subtract the next number in the sequence from the previous number so 2 from 1, 4 from 3 and so on. Ideally, it would find those "pairs" and then subtract the time from that row so I also need a way to do that
Assuming there are no sequential "START" options for the same behavior; Something along these lines:
Formula in F2:
=IF(D2="START",XLOOKUP(C2,C3:C$11,B3:B$11)-B2,"")
If I understand well, you want to subtract the timestamps when the status equals "STOP" and the previous status equals "START". For such situation, you might use the following formula:
=IF(AND(D2="START",D3="STOP"),B3-B2,"")
This puts the time difference in that particular case and a blank cell in the other case, resulting in something like this:
Difference
<BLANK>
9.8
<BLANK>
21.3
<BLANK>
12.8
...
(Keep in mind that I've used rounded values, which are slightly different than yours)

How might I achieve this custon number formatting in excel?

For the sake of this example:
100 copper = 1 silver
100 silver = 1 gold
100 gold = 1 platinum
I have a number that represents number of copper and I'd like to format it such that, in excel, it displays as a number of platinum, gold, silver, and copper. For example, "123456789" would display as "123p 45g 67s 89c". As far as I can tell, formulas by themselves are not an option because I'd like to do some operations on multiple columns that require everything to be in their base-copper representation (e.g. - "Highlight this cell if its contents are 10% higher than this other cell's contents"). As far as I can tell, I can't do this if the contents of a cell are something like "2g 4s", so I want only to display the contents as such.
I suppose one option is to have formulas, where one formula converts the copper value to plat-gold-silver-copper, while the other formula does the inverse? Then, in order to conditionally highlight certain cells, I make use of the inverse?
Something that we might be able to take advantage of is that copper-value numbers can just be split by two-digits each. For example, in 375938457, we know 57 is copper, 84 is silver, 93 is gold, and 375 is platinum. If any of the values are 00, we just omit them.
Is... this something that's too complicated for excel? Feel free to post any supplemental information or explain things in-depth. I'm very new to working with excel. (I'd like to do the same with milliseconds-to-hours/days/months aswell, which isn't as straightforward I think).
#0"p "00"g "00"s "00"c"
Unfortunately, I have only been able to test this in Google Sheets, not in Excel
Essentially, this just takes the formatting #0000000 (which will give you at least 7 digits), and shoves text strings for "p", "g", "s" in the middle, then shoves "c" on the end.
In Excel, but not Google Sheets, you can also have Value Conditions attached to conditional formatting, such as [>=5]"Lots";[>=4]"Many";#0 which would show the numbers 1-5 as "1, 2, 3, Many, Lots"
[>=1000000]#0"p "00"g "00"s "00"c";[>=10000]#0"g "00"s "00"c";[>=100]#0"s "00"c";#0"c"
Unfortunately, you can't use the formatting to make the extra 0 disappear between Platinum and Gold, Gold and Silver, or Silver and Copper.
123456789 will display as 123p 45g 67s 89c, but 246480369 will display as 246p 48g 03s 69c instead of 246p 48g 3s 69c
In Excel you can apply this from the "Number Format" at the bottom when you Right Click on a Cell and Format it (or press Ctrl+1). In Google Sheets, go Format > Number > More Formats > Customer Number Format
Doing this with seconds to hours / days / months is easy:
m" months, "d" days, "H" hours, "M" minutes, and "s" seconds"
Doing it with Milliseconds is not. Official Microsoft documentation about Number Formats can be found here

Controlling Excel time format input/output

Background: I have been officiating our local jogging events for about ten years now. I am responsible for handling the data of the participants (name, sporting club, bib number) split into their categories (age bracket+gender, distance). The main task is collecting their times, and processing that data (sorting the runners within their category etc). I can handle this with Excel mostly fine.
Problem: What is the ideal time format for entering the race times of the participants? The times are either in the format mm:ss or (for slower runners and/or longer distances) h:mm:ss. Excel doesn't seem to have a built-in format where the hours field is optional. For optimizing my workflow ideally I would like to have a cell format such that the input
47:12 is to be interpreted as 47 minutes and 12 seconds, and the input 1:09:38 is to be interpreted as 1hr 9 minutes and 38 seconds. However, Excel, with the best fitting cell format that I found, will insist that the input 47:12 means 47 hours and 12 minutes. For times exceeding 1 hour I would input 1:03:00 if I meant that the seconds field is to be left with value zero.
How to make Excel realize that when the format can handle up to three numbers as inputs, it would, when given only two numbers, move them towards the end?
Thinking: I "can" key in 47 minutes and 12 seconds as 0:47:12 all right. But because most of the times are under 1 hour, that is partly wasted effort. Also, using such a format the data is displayed on the screen together with that superfluous 0:. What's worse (IIRC) those leading zeros
also appear in the printed versions, which is strange (insulting even) in a shorter distance for junior participants.
My hack: I enter the times as general numbers in the mm,ss format (in these parts a comma serves as a decimal separator). Excel can sort those as numbers just fine. I then duplicate the data of that sorted column to another "printable" version (formatted as text), where the data is just copied, but I correct the times exceeding 60 minutes by hand. This works just fine as long as I'm not in a hurry (our event is not exactly Boston Marathon, say, less than 200 participants), and remember to hide the column that is not supposed to be printed. This is kludgy, and there have been accidents, when other officials have been rushing me to get the results printed.
I managed to create a format where the hour-field is optional. It works with a conditional format. First you format your cells as standard, so you get the times as comma-values. After that you create a conditional format for these cells, which has two rules:
if cellvalue > 0.04166667 format hh:mm:ss
if cellvalue < 0.04166666 format mm:ss
Result:
47:12
01:09:38
01:00:00
So you get what you really want and you can use the original values for sorting and so on.
EDIT:
For the input you need four additional columns. You enter the times as you want, e.g. 47:12 and 1:09:38. In the next three columns you split these values in hour, minute and second, whereby the interpretation limit is 3 hours (03:00), which is 0.125.
So, these are the formulas for the split columns (your input is in B1):
Hours: =IF(B1>0.125,0,HOUR(B1))
Minutes: =IF(B1>0.125,INT(B1)*24+HOUR(B1),MINUTE(B1))
Seconds: =IF(B1>0.125,MINUTE(B1),SECOND(B1))
And finally, you put all values togehter in the forth column:
=TIME(C1,D1,E1)
and use the conditional format above.
If you will be entering your data as
`mmm,ss`
where the comma is the decimal point, then you can convert it to "Excel Time" with the simple formula:
=DOLLARDE(A1,60)/1440
Format the result as you wish.
If you want everything displayed as h:mm:ss then use that as your custom format (Format > Cells > Number > Custom Type:...)
If you want h to be displayed only with values of 60 minutes or greater, then use
[<0.0416666666666667]mm:ss;h:mm:ss
for your cell's custom format.
Beware that seconds must be entered with two digits always. In other words
6,2 will translate to 6 min 20 sec.
6,02 will translate to 6 min 2 sec
I really like IQV's answer above, but as pointed out in the comment section, the leading zero will be required for the data entry side. If for whatever reason this is not acceptable you can use the following ugly formula to convert your time entered in your usual method of mm,ss to hh:mm:ss with the hh: being displayed as required. Unfortunately it converts the whole thing to text which means you can no longer perform math operations on it.
=IF(FIND(".",MOD(D2,60)&".")=2,"0","")&MOD(D2,60)
and since you use , as your decimal separator the formula would become:
IF(FIND(",",MOD(D2,60)&",")=2,"0","")&MOD(D2,60)
If you use ; as your list separator then your formula becomes
IF(FIND(",";MOD(D2;60)&",")=2;"0";"")&MOD(D2;60)
There are probably some cleaner formulas, but that will get you started. Just replace D2 with the location where your time is stored.
Again I still prefer IQV's answer as you can do much more with the time information when its stored as a number and not text.
Option 2
lets say you change your data storage method to hhmm,ss in cell D6. you could rip apart the information and reassemble it in a display friendly version as follows.
=IF(FIND(".",D6)<=3,LEFT(D6,2)&":"&RIGHT(D6,LEN(D6)-FIND(".",D6)),LEFT(D6,FIND(".",D6)-3)&":"&MID(D6,FIND(".",D6)-2,2)&":"&RIGHT(D6,LEN(D6)-FIND(".",D6)))
you will need to substitute your list separator for the , and then substitute a coma for the decimal.

Multiplying values in a matrix if criteria is met using an Excel formula, not VBA

Background
I have a matrix and I'm working to determine costing without having to have a separate table to show the cost values per line item. I would consider each value to consist of a 3x5 matrix, in this example, where the table/matrix shows an Area being worked in, the Rate for the line item, and the Value (values 0-29, 30 items).
The data is laid out as such:
Area Rate Value0 Value1
µ A 1 6
µ B 2 7
ö C 3 8
ö D 4 9
µ E 5 10
I am trying to find the total for Value0 and Value1 for each Area, µ and ö, such that:
Value0,µ=If(Area(A)=µ,A*1,0)+...+If(Area(E)=µ,E*5,0)
Value1,µ=If(Area(A)=µ,A*6,0)+...+If(Area(E)=µ,E*10,0)
Value0,ö=If(Area(A)=ö,A*1,0)+...+If(Area(E)=ö,E*5,0)
Value1,ö=If(Area(A)=ö,A*6,0)+...+If(Area(E)=ö,E*10,0)
Issue:
I have gone through and attempted to lay out the the above if-statement based additions of the multiplied values in the matrix. The example of A-E is small, but my actual set of data is roughly 200 lines. I am hoping to find a way to go this without using VBA, but am a bit unfamiliar with how to use arrays to do this, or if it is possible to check a scenario before multiplying.
Question:
Is it possible to set-up an equation to multiply like an array in Excel, without having to use the set-up I gave in the background (shown below so you don't have to scroll up).
Value0,µ=If(Area(A)=µ,A*1,0)+...+If(Area(E)=µ,E*5,0)
Any help/advice would be appreciated.

Microsoft Excel 2007 Always round up even if the decimal is under 0.5

So I'm creating a spreadsheet that determines the cost of materials and the number of each material needed in order to complete a desire project using input from myself. Right now the desired project is a wall that is 250x9 that requires replace all the 4x8 sheets of wood with OSB and install Vinyl Siding. The issue I'm running into is I cannot get it to always round up. By that I mean even if the value is 1.1 it should round up. In this specific case I am buying nails for my nail gun in a box of 2,000 and each sheet of OSB will have 32 nails in it. If 250x9 area requires 70.3125 sheets of OSB it means I still have to buy 71 sheets of OSB. If that OSB is 71 sheets then it require that I have 2272 Nails then the result is I need 1.125 Boxes of nails. However I can't seem to get it to show this as 2 boxes because again I still need to purchase more than one box to complete the project. So with that being said if I take the number of OSB needed 70.3125 and I place it in a formula with a roundup function it still rounds down (gives me a headache that there is a roundup and a rounddown function and it will still round down on me. Perhaps it is the way I am using it in the formula that is incorrect, I'm not sure. So let me translate the formula's used and you can let me know if I'm doing something wrong or if there is a function or set of functions that I can use to solve this issue.
=SUM(((B30*C30)+(B35*C35)+(E30*F30)+(H30*I30))/(E9*G9))
This says that if I added Wall1 L*W with Wall2 L*W with Wall3 L*W with Wall4 L*W and divide it by OSB H*W I get the number of sheets needed. Which in this case is 2250/32 basically. But its programmed in a manner that I can input the information for individual walls to different area's and get it to spit out the total SqFt for each wall and give an individual breakdown per wall of material needed with cost associated per sq ft of material bleh bleh bleh. The point is I take the result that is the 70.3125 and I move it to a different workbook and I say "Sheets OSB Needed" and in that box I have
=ROUNDUP(Sheet1!A9,1)
Whereas I'm asking it to roundup A9 which is the result of the above formula by intervals of 1. But the output is still 70 instead of 71. and much the same case with the nails needed. Which can be calculated in a few different manners but regardless the amount of nails needed divided by 2000 would output the decimal answer which yields a value of less than 1.5 and it too provides me with a value of 1 instead of 2 with much the same formula. I could achieve my desired result I suppose with Trunc and Mod functions collaborating using multiple cells to output the different portions of the data. But is there a way to do this that doesn't involve so many cells being used up?
C7
=Trunc(A9)
Removes Decimal from 70.3125
C8
=MOD(A9)
Outputs decimals from 70.3125
C9
=IF(C8<1,"1",C8)
If Decimals are < a whole number make it a whole number
C3
=SUM(C7+C9)
Add the whole number to the Trunc Number to get value desired.
Which I'm already seeing an issue with this if there is no decimals in the sheets needed then wouldn't it always add one because the decimal place would be 0? How can I handle this issue? Isn't there an easier way to do this or a way to code it so that its all nested into one calculation or at least mostly all into one calculation without making a circular reference of some sort?
You need to change the second parameter to a 0 ROUNDUP(70.3125, 1) is 70.3 the 3 must be getting dropped elsewhere or lost in formatting.
ROUNDUP(70.3125, 0) will give 71.
The second parameter of round up is the decimal place. So to round to integers it should be 0 not 1

Resources