Move rows to new tabs grouping multiple rows with same column values

johnasmith13

New Member
Joined
Apr 2, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I would like to have a macro that would move each lines of each employee to a separate tab that is the employee's name and leave the weekly summary tab as is.
The attached screen clip further explains!

Thank you so much!!

Rows to New Tabs by Employee Each 4-2-2021.xlsx
ABCDEFGHIJKL
1ID #Employee Code:#:Employee Name:DateINOUTINOUTDaily Clock HoursEligible?Worked AM - PMDaily Hours w/ Guarantee
22130J63864Employee1Tue 03/16/20216:51AM8:29AM10:09AM12:17PM
32130J63864Employee1Tue 03/16/20211:22PM3:16PM5.677Yes7
42130J63864Employee1Wed 03/17/20216:51AM8:28AM10:10AM11:53AM
52130J63864Employee1Wed 03/17/20211:22PM3:25PM5.387Yes7
62573I72647Employee2Tue 03/16/20216:50AM10:09AM1:28PM4:40PM6.527Yes7
72573I72647Employee2Wed 03/17/20216:45AM10:08AM1:22PM4:30PM6.527Yes7
82573I72647Employee2Thu 03/18/20216:50AM10:34AM1:25PM4:47PM7.17Yes7.1
92573I72647Employee2Fri 03/19/20216:49AM10:29AM3.677No3.67
102366G74253Employee3Tue 03/16/20215:40AM10:04AM10:12AM5:02PM11.237Yes11.23
112366G74253Employee3Wed 03/17/20215:34AM10:08AM10:31AM4:31PM10.577Yes10.57
122366G74253Employee3Fri 03/19/20215:47AM10:00AM11:41AM4:42PM9.237Yes9.23
132538L72170Employee4Tue 03/16/20215:49AM9:41AM9:50AM12:04PM
142538L72170Employee4Tue 03/16/202112:53PM4:44PM9.957Yes9.95
152538L72170Employee4Wed 03/17/20215:50AM12:19PM12:50PM4:56PM10.587Yes10.58
162538L72170Employee4Thu 03/18/20215:49AM12:10PM12:53PM4:47PM10.257Yes10.25
172538L72170Employee4Fri 03/19/20215:50AM12:03PM12:56PM4:47PM10.077Yes10.07
182131C63833Employee5Tue 03/16/20216:18AM9:31AM10:23AM11:51AM
192131C63833Employee5Tue 03/16/20211:19PM4:44PM8.17Yes8.1
202131C63833Employee5Wed 03/17/20216:37AM9:31AM10:28AM11:50AM
212131C63833Employee5Wed 03/17/20211:21PM4:49PM7.737Yes7.73
222131C63833Employee5Thu 03/18/20216:26AM9:30AM10:23AM11:50AM
232131C63833Employee5Thu 03/18/20211:22PM4:41PM7.837Yes7.83
242131C63833Employee5Fri 03/19/20216:32AM9:35AM10:29AM11:59AM
252131C63833Employee5Fri 03/19/20211:22PM5:00PM8.187No8.18
3-15 to 3-21-21 (Week)
 

Attachments

  • Example Screen Clip.PNG
    Example Screen Clip.PNG
    100.7 KB · Views: 6

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi johnasmith13, welcome to the MrExcel forum.

Does this do what you are looking for...

VBA Code:
Sub MoveRows()
    
    Dim arr
    Dim ws As Worksheet, wsMain As Worksheet
    Dim x As Long, i As Long
    Dim rng As Range, rng2 As Range
    
    Application.ScreenUpdating = False
    Set wsMain = ActiveSheet
    Set rng2 = ActiveSheet.UsedRange.Offset(1, 0)
    arr = rng2
    With CreateObject("Scripting.Dictionary")
    For x = LBound(arr) To UBound(arr) - 1
        If Not IsMissing(arr(x, 3)) Then .Item(arr(x, 3)) = 1
    Next
    arr = .Keys
    End With
    For i = LBound(arr) To UBound(arr)
        rng2.AutoFilter
        wsMain.Range("C1").AutoFilter
        wsMain.UsedRange.AutoFilter Field:=3, Criteria1:=arr(i), Operator:=xlFilterValues
        Set rng = ActiveSheet.AutoFilter.Range
        Set ws = Worksheets.Add
        rng.Copy Range("A1")
        ActiveSheet.Name = arr(i)
        wsMain.Activate
    Next
    ActiveSheet.AutoFilter.ShowAllData
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Solution
Hi johnasmith13, welcome to the MrExcel forum.

Does this do what you are looking for...

VBA Code:
Sub MoveRows()
   
    Dim arr
    Dim ws As Worksheet, wsMain As Worksheet
    Dim x As Long, i As Long
    Dim rng As Range, rng2 As Range
   
    Application.ScreenUpdating = False
    Set wsMain = ActiveSheet
    Set rng2 = ActiveSheet.UsedRange.Offset(1, 0)
    arr = rng2
    With CreateObject("Scripting.Dictionary")
    For x = LBound(arr) To UBound(arr) - 1
        If Not IsMissing(arr(x, 3)) Then .Item(arr(x, 3)) = 1
    Next
    arr = .Keys
    End With
    For i = LBound(arr) To UBound(arr)
        rng2.AutoFilter
        wsMain.Range("C1").AutoFilter
        wsMain.UsedRange.AutoFilter Field:=3, Criteria1:=arr(i), Operator:=xlFilterValues
        Set rng = ActiveSheet.AutoFilter.Range
        Set ws = Worksheets.Add
        rng.Copy Range("A1")
        ActiveSheet.Name = arr(i)
        wsMain.Activate
    Next
    ActiveSheet.AutoFilter.ShowAllData
    Application.ScreenUpdating = True
   
End Sub
Thank you for your reply! I got a 400 Error (see screen clip)...... Any suggestions?

John
 

Attachments

  • Error Screen Clip.PNG
    Error Screen Clip.PNG
    96.8 KB · Views: 6
Upvote 0
Great, I am glad you got it working, I was happy to help. Thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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