Formula for row artificial shift - excel

i've been doing this for weeks but to no avail, i'll give you the context so it'd be easier to understand: i have several sets of warehouse materiel codes sorted from smallest to largest as well as the time they need to be delivered to the workshop for processing and the amount of pallets required at each specific time frame, here is how it looks:
Mat. Code Time Pallets
65504606 07:30:00 2
65504606 10:30:00 1
65504606 13:30:00 2
65504606 16:30:00 1
65504606 19:30:00 2
65504606 22:30:00 1
65504606 01:30:00 2
65504606 04:30:00 1
I'm matching this data with another worksheet containing the information on where each individual pallet is stored, so i need to shift values in the time column so that a specific pallet is delivered on time, here's what i'd like it to look like:
Mat. Code location Time Cell shift
65504606 91-04-03/1 7 30 0
65504606 76-13-03/1 7 30 -1
65504606 97-19-03/1 10 30 -1
65504606 97-16-03/3 13 30 -1
65504606 76-19-02/1 13 30 -2
65504606 97-18-03/1 16 30 -2
65504606 97-18-03/2 19 30 -2
65504606 88-07-02/1 19 30 -3
I figured i could shift cells artificially by adding another column (cell shift - it has to be negative because the amount of rows in the sheet i'm matching with is smaller, plus i'm using INDEX - SMALL formula combination for matching each consecutive row of every set of codes), but all the formula combinations i've tried were giving me wrong numbers. The amount of pallets can vary from 0 to 9 and go in no particular order.
I know it's a lot of confusing information, but you would really help me out if you come up with a proper formula. Thanks in advance!

What you want to do is look something up in a restricted range.
What I did was restricting the range so I could use a simple VLOOKUP.
What OP asked for was an additional input to use in another formula.
=VLOOKUP(C2,OFFSET(YourFirstTableWithPalletNums!$A$1,MATCH(A2,YourFirstTableWithPalletNums!$A:$A,0)-1,1,COUNTIFS(YourFirstTableWithPalletNums!$A:$A,A2),2),2,FALSE)
P.S. Only works if the time values you look up are actually time values and not strings like the question implies.
EDIT:
=ROW(OFFSET(YourFirstTableWithPalletNums!$A$1,MATCH(WhereYouLookUpFrom!$C2,OFFSET(YourFirstTableWithPalletNums!$A$1,MATCH($A2,YourFirstTableWithPalletNums!$A:$A,0)-1,1,COUNTIFS(YourFirstTableWithPalletNums!$A:$A,$A2)),0),1))-ROW()
Then we need one more shift and then take the applicable row (we're still operating with ranges in this case). When added to the previously uploaded file it worked perfectly.

Related

Trying to create 2 columns out of 1 column of data using offset and indirect

Need to take 1 column of data and create 2 columns for maximizing the amount of data on each sheet.
Ive been working with offset and indirect formulas but not getting the expected results. Below are just a few examples of what ive tried and worked with and tried changing to get what i think i should be getting.
=IF(OFFSET(Sheet1!$A$1,(COLUMN()-1)*10+ROW()-1,0)="","",OFFSET(Sheet1!$A$1,(COLUMN()-1)*310+ROW()-1,0))
=OFFSET($A$1,ROW()*1-2+COLUMN(),0)&""
=INDIRECT("a"&ROW()*1-(2-COLUMN()))
So we have a need to create a excel template as dynamic as possible with as little printed pages as we can. Because the number of rows is unknown, we want to build the template in a fashion that allows for as little or as much data as we receive and need printed. So we have a need to fit 2 column sets per page, each set containing 10 rows each so we can have a total of 20 sets per page.
After finding offset and indirect, i started to work with that and see if i can create a formulas that would give me what we need..
What we are trying to see by using these formulas(if they are the correct ones to use) is the following:
Say we have 25 rows in our datasheet. We would like to see the following on our template.
Page 1
1 11
2 12
3 13
4 14
5 15
6 16
7 17
8 18
9 19
10 20
Page 2
21
22
23
24
25
Do not use INDIRECT and OFFSET if possible (And I have only found rare times they are needed) as they are volatile functions. Index is the best option:
Page1 put this in the first cell, copy over one and down ten:
=INDEX(Sheet1!$A:$A,Row(1:1)+((column(A:A)-1)*10))
In each sequential sheet add a factor of 20:
=INDEX(Sheet1!$A:$A,Row(1:1)+((column(A:A)-1)*10)+(20*1))
Change the *1 to *2 for the third and so on.

Distribute value equally over weeks by start- and end-date

I want to distribute a certain value (D4:D6) equally over the week-numbers (E3:J3) by its start- and end-date (B4:C6), as shown in the example.
A formula/vba script should do the following things:
Check which week-number the start- and end-date has
Divide the value by the amount of weeks between start- and end-date
Place the values in the matching column in the same row
The example in text format to copy:
2017 2018
Start End Value 50 51 52 1 2 3
26.12.2017 04.01.2018 20 - - 10 10 - -
12.12.2017 24.12.2017 50 25 25 - - - -
11.12.2017 10.01.2018 60 12 12 12 12 12 -
Also glad about hints / ideas how single steps could be achieved.
Proof of Concept:
place the following formula in E4 and copy down and right
=IF(WEEKNUM($C4,21)-WEEKNUM($B4,21)<0,IF(OR(E$3>=WEEKNUM($B4,21),E$3<=WEEKNUM($C4,21)),$D4/IF(WEEKNUM($C4,21)-WEEKNUM($B4,21)<0,MAX(WEEKNUM(DATE(YEAR($B4),12,{28,29,30,31}),21))-WEEKNUM($B4,21)+WEEKNUM($C4,21)+1,WEEKNUM($C4,21)-WEEKNUM($B4,21)+1),0),IF(AND(E$3>=WEEKNUM($B4,21),E$3<=WEEKNUM($C4,21)),$D4/IF(WEEKNUM($C4,21)-WEEKNUM($B4,21)<0,MAX(WEEKNUM(DATE(YEAR($B4),12,{28,29,30,31}),21))-WEEKNUM($B4,21)+WEEKNUM($C4,21)+1,WEEKNUM($C4,21)-WEEKNUM($B4,21)+1),0))
Now this is a built up formula from multiple cells that I back substitute the formulas to wind up with the monstrosity above. The break down is as follows.
STEP 1
Find the start week number. Place the following in B8.
=WEEKNUM($B4,21)
STEP 2
Find the end week number. Place the following in C8.
=WEEKNUM($C4,21)
STEP 3
Determine the maximum number of weeks in a year. Thanks to Ron Rosenfeld for this formula. Place the following in D8.
=MAX(WEEKNUM(DATE(YEAR($B4),12,{28,29,30,31}),21))
STEP 4
Determine if the week is in the same year or the following year. Place the following in E8.
=C8-B8
STEP 5
Determine the number of weeks. Place the following in F8.
=IF(E8<0,D8-B8+C8+1,C8-B8+1)
STEP 6
Average the value for each week. Place the following in G8.
=D4/F8
STEP 7
Determine if the average value belongs to a date header or the value of 0 (if you want an actual dash and not just formatting 0 as a dash then change 0 to -. Place the following formula in H8.
=IF($E8<0,IF(OR(E$3>=$B8,E$3<=$C8),$G8,0),IF(AND(E$3>=$B8,E$3<=$C8),$G8,0))
Copy the H8 formula to the right and down as required.
Caveat: Will work for a 1 year spread in work weeks. I have serious doubts that it would work over multi year start and end week.
Layout of steps

sumif range and criteria switching

So I have a table of number of fiscal weeks in a year, and to calculate depreciation I'm trying to sum the number of weeks in the total life of the capital investment. So the first argument is the range, the second argument pulls the year from another cell, and then adds the expected life in years of the device. The third argument is the intended sum range.
SUMIF(YearWeeks[Year],"<="&LEFT(AS$14,4)+$H20,YearWeeks[Weeks])
This works fine. Pulls in the right numbers no problem.
However, whenever I try and drag this across other cells so that it can be used throughout my spreadsheet to caculate depreciation, it immediately switches the value for year and the value for weeks and becomes:
SUMIF(YearWeeks[Weeks],"<="&LEFT(AU$14,4)+$H20,YearWeeks[Year])
I cannot figure out why it is doing this. It is probably something simple, but it is completely evading me. Any help would be greatly appreciated.
Year Weeks
2015 52
2016 53
2017 52
2018 52
2019 52
2020 52
2021 53
2022 52
2023 52
2024 52
2025 52
2026 52
2027 53
2028 52
2029 52
2030 52
Life
5
5
5
5
5
5
5
5
8
8
8
8
8
8
201504 201505 201506 201507 201508 201509 201510 201511 201512 201601 201602 201603
Instead of dragging the formula to the right, copy the cell and paste it in the cell at the right of it, etc... :
This will keep the column references unchanged (no change from YearWeeks[Weeks] to YearWeeks[Year]).
As specified on Microsoft's support website:
Moving, copying, and filling structured references
All structured references remain the same when you copy or move a formula that uses a structured reference.
When you fill a formula, fully qualified structured references can adjust the column specifiers like a series as summarized in the following table.
NB: YearWeeks[Weeks] is a structured reference, and fill is what many would call drag in this context.

Round time to nearest 15 minutes

I'm trying to round my overtimes in Excel and I found 2 formulas:
=FLOOR(A1,"00:15")
as well as
=ROUNDDOWN((A1)*(24*60/15),0)/(24*60/15)
and they both failed when there was a time which does NOT need rounding down.
It is all good when I want to round down e.g. 01:29 to 01:15 or 00:48 to 00:45, but when I have e.g. 01:30 it rounds it down to 01:15, when obviously I need to leave it as it is:/
A1 is the example cell when my time is stored.
for 01:30, this formula:
=FLOOR(A1,"00:15")
returns 01:30 for me.
I am on Excel 2010
Like others have said, =FLOOR(A1,"00:15") should work, but if your version of Excel doesn't do the right thing for some reason, this should work:
=TIME(HOUR(A1),FLOOR(MINUTE(A1)/15,1)*15,0)
=FLOOR(D4*96;1)/96 works fine.
Why 96 ? Because for time units, 1 = 1 day, so 1 hour = 1/24.
You multiply by 24 then by 4 (for quarters), then floor, then divide by 4 to get rounded quarters.

If Statement to check time in excel

I need to create an if statement to check time in excel. For instance if time is between
00:00:01 to 06:00:00 I give a value of 1
if time is 06:00:01 to 12:00:00 I give a value of 2
if time is 12:00:01 to 18:00:00 I give a value of 3
and if time is 18:00:01 to 00:00:00 I give a value of 4
Any ideas how I should implement this?
Assuming that the time is in cell A1, you could use:
=CEILING(A1/0.25,1)
It worked on some sample data for me:
12:01:03 3
18:19:00 4
00:00:01 1
The above works because dates are actually numbers in Excel, and 1 unit represents 1 day. So naturally, if you divide 1 day by 4, you get what you are looking for.
You can use Excel Worksheet formula like shown below (it reads the system time using function NOW()):
=IF(HOUR(NOW())>18,4,IF(HOUR(NOW())>12,3,IF(HOUR(NOW())>6,2,1)))
If HOUR is already given in, for e.g., column A1, then use a simplified formula:
=IF(A1>18,4,IF(A1>12,3,IF(A1>6,2,1)))
Try this
=TEXT(IF(INT(TEXT(A1,"[m]"))<=360,1,IF(INT(TEXT(A1,"[m]"))<=720,2,IF(INT(TEXT(A1,"[m]"))<=1080,3,IF(INT(TEXT(A1,"[m]"))<=1440,4,"")))),"#")

Resources