How to sort varying range of data into weekly buckets

selenebean

New Member
Joined
Jan 5, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I'm trying to create essentially a demand spreadsheet. I want the customer to be able to input the item and location they plan to sell something, the start week of selling, how many total weeks they expect to sell the item, and the # of items they expect to sell in a week. I want to then take this data input, and create a table/sheet with the demand by week for each item/location pair. I'm having a hard time figuring out how to have Excel sort through a range of data inputs to find the right data, as well as then input that data for each week between the start and end date. The # of inputs will vary (i.e. there could be 12 lines of data or 200), and there will sometimes be seasonality for when the customer expects to sell items. Image attached which probably better explains what I'm trying to do.

Appreciate any help I can receive! I'm not opposed to having Excel automatically manipulate the customer data input to put it in an easier way for Excel to then input into the weekly chart.

r/excel - How to sort varying range of data into weekly buckets
  • Excel Version: Office 365 but needs to be compatible with other versions of Excel (i.e. sadly no XLOOKUP and other 365 only functions)
  • Excel Environment: desktop, Windows
  • Your Knowledge Level: Intermediate?
  • Open to Macros and other fancy tools, but must admit I've never used Power Query or Power BI. Needs to be able to be used by customer (AKA dummy proof, and any add-ons need to be free and easy to add to Excel)
 

Attachments

  • image (2).png
    image (2).png
    77.9 KB · Views: 4

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
with a macro "unpack", 2 listobjects and 1 pivottable
VBA Code:
Sub Unpack()
     Set dict = CreateObject("scripting.dictionary")
     With Sheets("selenebean")
          a = .ListObjects("TBL_Data").DataBodyRange.Value2
          For i = 1 To UBound(a)
               datum = CDbl(a(i, 3) - WorksheetFunction.Weekday(a(i, 3)) + 1)
               For j = 1 To a(i, 4)
                    d = datum + (j - 1) * 7
                    dict.Add dict.Count, Array(a(i, 1), a(i, 2), d, a(i, 6), Year(d), WorksheetFunction.WeekNum(d))
               Next j
          Next i

          With .ListObjects(2)
               If .ListRows.Count Then .DataBodyRange.Delete
               If dict.Count Then
                    a = Application.Index(dict.items, 0, 0)
                    .ListRows.Add.Range.Range("A1").Resize(UBound(a), UBound(a, 2)).Value = a
               End If
          End With
     End With

     ThisWorkbook.RefreshAll
End Sub



amoverton2 - 1.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1storeitemstartweek# weeksEnd weekweekly demandStartweeknumberEndweeknumberstoreitemSundaydemandyearweek2
2Denverpurse01/01/22201/15/22213Denverpurse12/26/212202153Som van demanditemstore
3denverpurse01/01/23201/15/23213Denverpurse01/02/22220222purseTotaal pursebackpackTotaal backpackbeanieTotaal beanieEindtotaal
4LApurse03/01/22203/15/2221012denverpurse01/01/23220231yearweek2SundayDenverLADenverLADenverLA
5LApurse08/01/22208/15/2223234denverpurse01/08/2322023220215312/26/21222246
6LApurse01/01/23201/15/23213LApurse02/27/222202210
7denverbackpack01/01/22201/15/22213LApurse03/06/2222022112022201/02/22222246
8labackpack01/01/22201/15/22213LApurse07/31/22220223220221002/27/22222
9denverbeanie10/01/22210/15/2224042LApurse08/07/22220223320221103/06/22222
10labeanie10/01/22210/15/2224042LApurse01/01/2322023120223207/31/22222
11LApurse01/08/2322023220223308/07/22222
12denverbackpack12/26/21220215320224009/25/222244
13denverbackpack01/02/2222022220224110/02/222244
14labackpack12/26/212202153
15labackpack01/02/222202222023101/01/232244
16denverbeanie09/25/2222022402023201/08/232244
17denverbeanie10/02/222202241
18labeanie09/25/222202240Eindtotaal8122044844836
19labeanie10/02/222202241
20
21
22
23
24
25
Selenebean
Cell Formulas
RangeFormula
G2:G10G2=WEEKNUM([@startweek])
H2:H10H2=WEEKNUM([@[End week]])
E2:E10E2=+[@startweek]+[@['# weeks]]*7
 
Upvote 0

Forum statistics

Threads
1,214,629
Messages
6,120,630
Members
448,973
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top