Data Match with existing axes

Luke777

Board Regular
Joined
Aug 10, 2020
Messages
246
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I asked a similar question a week or two ago, but I was a little vague with exactly what I was looking for so the answers given (whilst great) often came with more questions from myself.

To skip to the important part I have a data source that looks like the following. All sheets are contained within one workbook. The below is taken from Worksheets("Source").

28606:30:0046
21406:30:0046
153506:30:0046
158006:30:0046
130706:30:0046
102906:30:0053
5706:30:0023
28606:45:0012
21406:45:0012
153506:45:0012
158006:45:0012
130706:45:0012
93207:30:0046
53807:30:0046
93207:45:0012
54207:45:0046
53807:45:0012
54208:00:0012
24108:00:0046
98908:00:0023


This is only the first 20 rows. The data currently goes down to 342, but is variable - though I would be quite shocked if the value was ever above 5k. The data is also sorted by date/time as per B:B - the earliest date/time will always be first.

I wish to create a table (I don't specifically mean the table feature in excel but table rather just organise the data in a more readable way) where the numbers in A:A act as a header across the top starting in C1. These headers should be unique (note values in A:A appear more than once, but the data should be consolidated if that makes sense). This 'table' will be on Worksheets("Results")

The date/time axis should begin in A4 - though this is where things are a little tricky. As per the source data, the first time would be 6:30 on the given date. Times are also dealt with in 15 minute intervals. however, notice that B12:B13 skips 45 minutes (three intervals or so). This means that using B:B as the Axis on the final table is not desireable as the axis may have missing chunks of time depending on the source data. To get around this, the date/time axis already exists on the result sheet - I have a bit of code that looks for the time in B1, places it in A4 and loops through rowno 4 To 148 (final row ~ 36 hours from start time but this doesn't really matter at this stage) adding 15 minutes each step.

With the example source data, the Results sheet should look like below - I'm looking for a VBA solution to this

ID#286214153515801307102957932538542241989
Part (ignore)/////////
Time
06:30:0046464646465323
06:45:001212121212
07:00:00
07:15:00
07:30:00464646
07:45:001212
08:00:00124623


The gap in B and rows 2,3 is deliberate, I'll be adding other data as part of a sep process in those spaces - though if needs be, these can be ignored and I can simply add an extra column and two new rows at a later time.

I think I've covered everything, but if I've missed anything crucial, please let me know.
 
Here you go. Even more dynamic. :) This will find the end of your data on sheet1.

Book1
ABCDEFGHIJKLMN
1ID#286214153515801307102957932538542241989
2Part (ignore)
3Time
46:30 AM46464646465323
56:45 AM1212121212
67:00 AM
77:15 AM
87:30 AM4646
97:45 AM121246
108:00 AM124623
Sheet2
Cell Formulas
RangeFormula
C1:N1C1=TRANSPOSE(FILTER(UNIQUE(INDIRECT("Sheet1!A1:A" & MAX((Sheet1!A:A<>"")*(ROW(Sheet1!A:A))))),UNIQUE(INDIRECT("Sheet1!A1:A" & MAX((Sheet1!A:A<>"")*(ROW(Sheet1!A:A)))))<>0))
C4:N10C4=XLOOKUP(C1#&ROUND(A4:A10,5),Sheet1!A1:A20&ROUND(Sheet1!B1:B20,5),Sheet1!C1:C20,"")
A5:A10A5=A4+TIME(0,15,0)
Dynamic array formulas.
I ended up trying...

Excel Formula:
=XLOOKUP(C1#&ROUND(A4:A148,5),'All Activity'!A1:INDEX('All Activity'!A:A,COUNTA('All Activity'!A:A))&ROUND('All Activity'!B1:INDEX('All Activity'!B:B,COUNTA('All Activity'!B:B)),5),'All Activity'!C1:INDEX('All Activity'!C:C,COUNTA('All Activity'!C:C)),"")

just minutes before your post :) "All Activity" is the equivalent of sheet1 - it seems to do exactly the same thing as far as I can tell through testing. Is there any advantage/disadvantage to either method or just two ways of getting the same result? Though your method seems significantly shorter and simpler and probably better because of it :P

Also, thanks for your help!
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
For the C1 formula I would use
Excel Formula:
=LET(Rws,COUNTA('All Activity'!A:A),rng,'All Activity'!A1:INDEX('All Activity'!A:A,Rws),TRANSPOSE(UNIQUE(rng)))
which is non-volatile.
 
Upvote 0
And a slightly shorter version of your formula for C4
Excel Formula:
=LET(Rws,COUNTA('All Activity'!A:A),Rng,'All Activity'!A1:INDEX('All Activity'!C:C,Rws),XLOOKUP(C1#&ROUND(FILTER(A4:A148,A4:A148<>""),5),INDEX(Rng,,1)&ROUND(INDEX(Rng,,2),5),INDEX(Rng,,3),""))
 
Upvote 0
For the C1 formula I would use =LET(Rws,COUNTA('All Activity'!A:A),Rng,'All Activity'!A1:INDEX('All Activity'!C:C,Rws),XLOOKUP(C1#&ROUND(FILTER(A4:A148,A4:A148<>""),5),INDEX(Rng,,1)&ROUND(INDEX(Rng,,2),5),INDEX(Rng,,3),""))
Without a doubt, this is a better formula.

And a slightly shorter version of your formula for C4 =LET(Rws,COUNTA('All Activity'!A:A),Rng,'All Activity'!A1:INDEX('All Activity'!C:C,Rws),XLOOKUP(C1#&ROUND(FILTER(A4:A148,A4:A148<>""),5),INDEX(Rng,,1)&ROUND(INDEX(Rng,,2),5),INDEX(Rng,,3),""))
This one? I have to ask. How is this shorter than =XLOOKUP(C1#&ROUND(A4:A10,5),Sheet1!A1:A20&ROUND(Sheet1!B1:B20,5),Sheet1!C1:C20,"")
 
Upvote 0
It's not, but it is shorter than the OP's formula which is using a dynamic range, rather than a hardcode one. ;)
 
Upvote 0
old school method with a pivottable, refresh speed instantly ?
you want a different layout that that fixed layout ???
Place the pivottable in a dark corner of your sheet and the wanted layout is defined by the named range "TopLeft", here G25.
The 3 colored parts of the pivottable are copied to your layout.

VBA Code:
Sub kopieren()
     Set pvt = Sheets("blad1").PivotTables(1)
     With pvt
          Set rr = .RowRange
          Set cr = .ColumnRange
          Set dbr = .DataBodyRange
     End With

     With Range("Topleft")
          .Offset(3).Resize(100, 100).ClearContents
          .Offset(, 1).Resize(, 99).ClearContents

          With .Offset(, 2).Resize(1, cr.Columns.Count)
               .Value = cr.Offset(cr.Rows.Count - 1).Value
               .Interior.Color = RGB(255, 0, 0)
          End With

          With .Offset(3).Resize(-dbr.Row + rr.Row + rr.Rows.Count, 1)
               .Value = rr.Offset(dbr.Row - rr.Row).Value
               .NumberFormat = "hh:mm:ss"
               .Interior.Color = RGB(0, 0, 255)
          End With

          With .Offset(3, 2).Resize(dbr.Rows.Count, dbr.Columns.Count)
               .Value = dbr.Value
               .Interior.Color = RGB(0, 255, 0)
          End With
     End With
End Sub

luke777.xlsm
ABCDEFGHIJKLMNOPQRST
1customertimenrs
22866:30:0046Som van nrsKolomlabels
32146:30:0046Rijlabels572142412865385429329891029130715351580
415356:30:00466:30:0023464653464646
515806:30:00466:45:001212121212
613076:30:00467:30:004646
710296:30:00537:45:00124612
8576:30:00238:00:004612
92866:45:00129:00:0023
102146:45:0012
1115356:45:0012
1215806:45:0012ID#286214153515801307102957932538542241989
1313076:45:0012Part (ignore)/////////
149327:30:0046Time
155387:30:00466:30:0046464646465323
169327:45:00126:45:001212121212
175427:45:00467:00:00
185387:45:00127:15:00
195428:00:00127:30:00464646
202418:00:00467:45:001212
219899:00:00238:00:00124623
22
23
24
25ID#572142412865385429329891029130715351580
26Part (ignore)/////////
27Time
2806:30:0023464653464646
2906:45:001212121212
3007:30:004646
3107:45:00124612
3208:00:004612
3309:00:0023
34
Blad1
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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