Find and transpose ranges as blocks.... I think?

picklefactory

Well-known Member
Joined
Jan 28, 2005
Messages
506
Office Version
  1. 365
Platform
  1. Windows
Hi folks
Trying to help our finance lady out with simplifying pay calcs. We have our company ERP systems collecting employee clockings but the format it outputs is not very amenable for manipulating the data, at least not for my meagre talents. The sample below shows the format of the report that's exported from the ERP, you can see that the number of entry rows can vary by employee, and some will include absences/holiday where applicable. I can't change the format of the export.
What I'm trying to do is grab each 'block' of data for each employee from the columnar format and transpose them so I have horizontal 'blocks' of data. In my head I then have short columns of data for each employee that I can add formulae to underneath and jiggle about with the data as I wish, I'm struggling to do that now as each employee block of data can vary and I'm not smart enough to find/index and manipulate where the position of entries is constantly varying. What I'd like to achieve is shown in the 2nd sample but I can't see a way to define each block, and then move it to a dynamically adjacent position to previous blocks.
Am I barking up the wrong tree, or is that doable?
Thanks



CLOCK ON OFF2.xls
ABCDEF
1530100A NOTHER
15402/03/2020 09:15:06 02/03/2020 16:05:47 6.83
15503/03/2020 06:28:08 03/03/2020 16:02:58 9.57
15604/03/2020 06:29:53 04/03/2020 16:05:42 9.60
15705/03/2020 06:27:53 05/03/2020 16:04:08 9.62
15806/03/2020 06:30:15 06/03/2020 15:33:58 9.05
15944.67
160Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S
161
162
163
164
1650101B NOTHER
16602/03/2020 10:16:48 02/03/2020 16:03:48 5.78
16703/03/2020 06:55:10 03/03/2020 16:03:20 9.13
16804/03/2020 07:00:17 04/03/2020 16:03:03 9.05
16905/03/2020 07:00:28 05/03/2020 16:02:41 9.03
17006/03/2020 06:58:46 06/03/2020 15:32:11 8.57
17141.57
172Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S
173
174
175
176
1771002C NOTHER
17804/03/2020 06:56:29 04/03/2020 16:02:09 9.10
17905/03/2020 06:56:24 05/03/2020 16:03:20 9.12
18006/03/2020 06:56:14 06/03/2020 15:32:45 8.60
18126.82
182Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S
1831002
1841002 03/03/2020F070000163000H
185
186
Sheet1



CLOCK ON OFF2.xls
ABCDEFGHIJKLMNOPQRST
1530100A NOTHER0101B NOTHER1002C NOTHER
15402/03/2020 09:15:06 02/03/2020 16:05:47 6.8302/03/2020 10:16:48 02/03/2020 16:03:48 5.7804/03/2020 06:56:29 04/03/2020 16:02:09 9.10
15503/03/2020 06:28:08 03/03/2020 16:02:58 9.5703/03/2020 06:55:10 03/03/2020 16:03:20 9.1305/03/2020 06:56:24 05/03/2020 16:03:20 9.12
15604/03/2020 06:29:53 04/03/2020 16:05:42 9.6004/03/2020 07:00:17 04/03/2020 16:03:03 9.0506/03/2020 06:56:14 06/03/2020 15:32:45 8.60
15705/03/2020 06:27:53 05/03/2020 16:04:08 9.6205/03/2020 07:00:28 05/03/2020 16:02:41 9.0326.82
15806/03/2020 06:30:15 06/03/2020 15:33:58 9.0506/03/2020 06:58:46 06/03/2020 15:32:11 8.57Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S
15944.6741.571002
160Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_SEmployee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S1002 03/03/2020F070000163000H
Sheet1
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Me again.
Please belay all that guff above.... I have since discovered that I can indeed modify the output format from the ERP to something much easier to work with, so I am sorted via another route. Please don't waste any time on this.... if anyone was!!! :)
Thanks folks
 
Upvote 0
I just got done with macro so you could give it a try. The macro assumes your data starts in row 1.
VBA Code:
Sub TransposeRanges()
    Application.ScreenUpdating = False
    Dim fRow As Long, lastRow As Long, i As Long, x As Long: x = 8
    With Range("A:A").SpecialCells(xlCellTypeConstants).Areas
        fRow = .Item(1).Cells.Count
        With .Item(.Count).Cells
            lastRow = .Item(.Cells.Count).Row
        End With
        For i = 2 To .Count
            .Item(i).Resize(, 6).Copy Cells(1, x)
            x = x + 7
        Next i
    End With
    Rows(fRow + 1 & ":" & lastRow).Delete
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks mumps.... in hindsight I should leave this open as I might still find an easier method via Excel.
I'll get back to you in a minute when I've tried that
 
Upvote 0
Genius..... that was exactly what I was utterly stumped with. Always a mystery to me how you guys seem to do this so easily. That's perfect thank you mumps.
 
Upvote 0
Bugger!
I'm back again. Only just found time to get back onto this and I'm afraid that code doesn't work quite as well as I first thought, although it gets close, but I'm missing some rows. If I'm not mistaken, that is transposing a fixed size range at a time? What I get when it runs is, it finds the first line for each employee, perfect, but then it is selecting a fixed 7 rows and transposing. The problem is... the ranges it needs to transpose are NOT a consistent size and they vary from employee to employee. I'm thinking I maybe didn't post the best example, I hope this one is clearer for what I need to see. The top section is what I'd like to see, the lower section is what mump's code is actually giving me, as you can see, some of the ranges are cut off short of a few rows. Is that an easy fix?
Thanks again for any time spent on this.

PAY CALCS.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
10008A NOTHER0011B NOTHER0100C NOTHER1010D NOTHER6666E NOTHER
209/03/2020 05:23:44 09/03/2020 14:02:07 8.6509/03/2020 06:54:13 09/03/2020 16:04:15 9.1712/03/2020 06:29:06 12/03/2020 16:05:38 9.6009/03/2020 05:49:02 09/03/2020 14:10:25 8.3510/03/2020 08:21:47 10/03/2020 16:30:51 8.15
310/03/2020 05:22:27 10/03/2020 14:02:03 8.6710/03/2020 06:52:35 10/03/2020 16:03:44 9.1813/03/2020 06:27:22 13/03/2020 15:36:58 9.1510/03/2020 05:50:30 10/03/2020 14:09:03 8.3211/03/2020 08:24:57 11/03/2020 16:43:52 8.32
411/03/2020 05:28:18 11/03/2020 14:02:06 8.5718.3518.7511/03/2020 05:55:37 11/03/2020 14:13:02 8.3013/03/2020 08:24:23 13/03/2020 16:02:43 7.63
512/03/2020 05:27:10 12/03/2020 14:02:02 8.58Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_SEmployee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S12/03/2020 05:53:50 12/03/2020 14:05:53 8.2024.10
613/03/2020 05:25:56 13/03/2020 14:02:08 8.620011010033.17Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S
743.080011 11/03/2020F070000160000S0100 09/03/2020F073000170000HEmployee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S
8Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S0011 12/03/2020F070000160000S0100 10/03/2020F073000170000H1010
90011 13/03/2020F070000160000S0100 11/03/2020F073000170000H1010 13/03/2020F070000140000H
10
11
120008A NOTHER0011B NOTHER0100C NOTHER1010D NOTHER6666E NOTHER
1309/03/2020 05:23:44 09/03/2020 14:02:07 8.6509/03/2020 06:54:13 09/03/2020 16:04:15 9.1712/03/2020 06:29:06 12/03/2020 16:05:38 9.6009/03/2020 05:49:02 09/03/2020 14:10:25 8.3510/03/2020 08:21:47 10/03/2020 16:30:51 8.15
1410/03/2020 05:22:27 10/03/2020 14:02:03 8.6710/03/2020 06:52:35 10/03/2020 16:03:44 9.1813/03/2020 06:27:22 13/03/2020 15:36:58 9.1510/03/2020 05:50:30 10/03/2020 14:09:03 8.3211/03/2020 08:24:57 11/03/2020 16:43:52 8.32
1511/03/2020 05:28:18 11/03/2020 14:02:06 8.5718.3518.7511/03/2020 05:55:37 11/03/2020 14:13:02 8.3013/03/2020 08:24:23 13/03/2020 16:02:43 7.63
1612/03/2020 05:27:10 12/03/2020 14:02:02 8.58Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_SEmployee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S12/03/2020 05:53:50 12/03/2020 14:05:53 8.2024.10
1713/03/2020 05:25:56 13/03/2020 14:02:08 8.620011010033.17Employee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S
1843.080011 11/03/2020F070000160000S0100 09/03/2020F073000170000HEmployee_Clock_NoDateFull_or_Half_DayFrom_TimeTo_TimeCode_H_or_S
19
20
Sheet3
 
Upvote 0
Is it possible to find each 4 digit clock number and set as first row of range to transpose, and then find next 4 digit clock number and use that (row-1) for last row of range to transpose?
I wish I knew more :(
 
Upvote 0
How about
VBA Code:
Sub picklefactory()
   Dim i As Long
   
   With Range("A:A").SpecialCells(xlConstants).Areas
      For i = 2 To .Count
         With .Item(i).CurrentRegion
            .Copy Cells(1, (i - 1) * 8)
            .ClearContents
         End With
      Next i
   End With
End Sub
 
Upvote 0
That's got the bugger!!!
Double checked this time, and that works exactly as I hoped. Thanks again Fluff, that's bob on. Thanks again also to mumps for the initial help with my crappy explanation.
:)
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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