Copy range from string until reach another string

lmcquade91

New Member
Joined
Sep 29, 2024
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi guys!

I am fairly new to coding and have been playing around, so am self taught.

I am having some trouble with the below.

I have a CSV file containing 14 days of roster data. I want to copy each day's data onto a new sheet.

I was thinking of using cells.find to look for the string "loc" as that separates each days data, but am not sure how to copy FROM that string UNTIL reaching next one.

if anyone can give me some code or help me out it would be greatly appreciated!! Thank you guys! :)
 
Hi Lara

Delete the previous code and use this code.

Do you do this one source sheet at a time?

Would it be handy to have a means to select the workbook to import the source data sheet from?

I have used the name of 'Structured' for the source data sheet.
If it is any different then just change this line.
Set WsData = Worksheets("Structured")

Run the subImportAndSplitData procedure.

VBA Code:
Private Sub subImportAndSplitData()
Dim rngFound As Range
Dim rng As Range
Dim r As Range
Dim arr() As String
Dim Ws As Worksheet
Dim WsData As Worksheet
Dim i As Integer

  ActiveWorkbook.Save
 
  Set WsData = Worksheets("Structured")
 
  WsData.Activate

  Set rngFound = fncFindValueInRange(WsData.UsedRange.Columns(1), "Loc")
   
  If Not rngFound Is Nothing Then
    For Each rng In rngFound.Cells
      arr = Split(rng.Offset(-4, 0).Value, " ")
      Set Ws = fncCreateSheet(ActiveWorkbook, arr(1) & " " & arr(2))
      rng.CurrentRegion.Copy Destination:=Ws.Range("A1")
      i = i + 1
    Next rng
  End If
 
  MsgBox "Data has been processed and " & i & " sheets have been created.", vbOKOnly, "Confirmation"
 
End Sub

Private Function fncFindValueInRange(rngToLookIn As Range, strLookFor As String) As Range
Dim rng As Range
Dim intFirst As Integer
Dim rngUnion As Range

    With rngToLookIn
       
      Set rng = .Find(strLookFor, LookIn:=xlValues, Lookat:=xlWhole)
     
      If Not rng Is Nothing Then
     
        intFirst = rng.Row
         
        If Not rngUnion Is Nothing Then
          Set rngUnion = Union(rngUnion, rng)
        Else
          Set rngUnion = rng
        End If
       
        Do
       
          Set rng = .FindNext(rng)
          If Not rng Is Nothing Then
            If rng.Row <= intFirst Then
              Exit Do
            Else
              Set rngUnion = Union(rngUnion, rng)
            End If
          End If
         
        Loop While Not rng Is Nothing
       
      End If
     
    End With
   
    If Not rngUnion Is Nothing Then
      Set fncFindValueInRange = rngUnion
    End If
   
End Function

Private Function fncCreateSheet(Wb As Workbook, strWorksheet As String) As Worksheet

  Application.DisplayAlerts = False
  On Error Resume Next
  Wb.Worksheets(strWorksheet).Delete
  On Error GoTo 0
  Application.DisplayAlerts = True
 
  Wb.Sheets.Add after:=Wb.Sheets(Wb.Sheets.Count)

  ActiveSheet.Name = strWorksheet
 
  Set fncCreateSheet = ActiveSheet

End Function
High and Wilder!!!! Thank you!!

I am having so much fun :) Sorry for my delayed response as I returned home late from work and then was reading through your code so I can learn from it! Then added some sort and replace stuff. Honestly I can't thank you enough!!

Your code works perfectly!!!

Currently I´ve got the below macros which all work perfectly, and eventually once I've got everything working I will combine :)

1) Convert the data from a webpage to excel
2) Your amazing Import and Split
3) Column rearrange on all sheets
4) Sort and Replace SUP with ASUP for all sheets

The last 1 I need is very hard
5) List all staff under corresponding role headings for all sheets. ( I have attached a photo of how I would like everything to look) I am guessing this is a complex Macro, far beyond my knowledge!

Again, I do not expect you to do this if you don´t have time, I am appreciative of any guidance you can give me from your brain :)

Have a wonderful day!!

Lara x
 

Attachments

  • test 2.JPG
    test 2.JPG
    131.4 KB · Views: 6
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
High and Wilder!!!! Thank you!!

I am having so much fun :) Sorry for my delayed response as I returned home late from work and then was reading through your code so I can learn from it! Then added some sort and replace stuff. Honestly I can't thank you enough!!

Your code works perfectly!!!

Currently I´ve got the below macros which all work perfectly, and eventually once I've got everything working I will combine :)

1) Convert the data from a webpage to excel
2) Your amazing Import and Split
3) Column rearrange on all sheets
4) Sort and Replace SUP with ASUP for all sheets

The last 1 I need is very hard
5) List all staff under corresponding role headings for all sheets. ( I have attached a photo of how I would like everything to look) I am guessing this is a complex Macro, far beyond my knowledge!

Again, I do not expect you to do this if you don´t have time, I am appreciative of any guidance you can give me from your brain :)

Have a wonderful day!!

Lara x
Lara

All of that is quite easily possible.

The code will sort the data by the Start and End date, replace SUP in the Role column with ASUP and reorder the columns.

Breakfast first though.
 
Upvote 0
Lara

All of that is quite easily possible.

The code will sort the data by the Start and End date, replace SUP in the Role column with ASUP and reorder the columns.

Breakfast first though.

Hi Lara

Here is the next version.

If I was you, I would create a new workbook and paste this code into a main code module. This is the best way to test it.

Copy the source data worksheet into this workbook and call it ‘Structured’ although we can change the name later.

Run the ‘subImportAndSplitData’ procedure.

A separate formatted sheet is created for each date in the ‘Structured’ worksheet.

It creates a worksheet name ‘Role Colours’ which contains the colours to use for each Role. I’m not sure if what you posted was just an example of what you wanted or the actual colours. Change the background colours for each Role on this sheet and these will be used for each result sheet when you next run the code. The ‘Role Colours’ worksheet will only be created if it does not already exist.

Do you have more Roles than the ones that I know about?

There are several procedures in the module that you may find useful in the future.

Let me know if it works as you want it to or if you need

VBA Code:
Option Explicit

Public Sub subImportAndSplitData()
Dim i As Integer
Dim WsData As Worksheet
Dim arrData() As Variant
Dim arrDate() As String
Dim rngLoc As Range
  
  ActiveWorkbook.Save
  
  Call subCreateRoleColoursTab
  
  Set WsData = Worksheets("Structured")
  
  WsData.Columns("D").Replace What:="SUP", Replacement:="ASUP", SearchOrder:=xlByRows, MatchCase:=True
  
  arrData = WsData.UsedRange
  
  For i = LBound(arrData) To UBound(arrData)
    
    If arrData(i, 1) = "Loc" Then
    
      Set rngLoc = WsData.Range("A" & i)
      
      With rngLoc
      
        arrDate = Split(.Offset(-4, 0).Value, " ")
    
        Call subCreateWorksheets(rngLoc, arrDate(1) & " " & arrDate(2))
      
      End With
            
    End If
    
  Next i
  
  MsgBox "Data has been processed and separate sheets been created.", vbOKOnly, "Confirmation"

End Sub

Private Sub subCreateWorksheets(rng As Range, strWorksheetName As String)
Dim Ws As Worksheet
             
  Set Ws = fncCreateSheet(ActiveWorkbook, strWorksheetName)
         
  With rng.CurrentRegion
    Ws.Range("A1").Formula2 = "=CHOOSECOLS(VSTACK(TAKE('" & .Parent.Name & "'!" & .Address & ",1),SORT(" & _
    "'" & .Parent.Name & "'!" & .Offset(1, 0).Resize(.Rows.Count - 1.7).Address & ",{4,5,6})),6,5,7,4,2,3,1)"
  End With
        
  With Ws.Range("A1").CurrentRegion
    .Value = .Value
    .Columns("E:F").NumberFormat = "HH:MM"
  End With
  
  Call subSplitByRole(Ws)
  
End Sub

Private Sub subFormatSheet(Ws As Worksheet)

  With Ws.Range("A1").CurrentRegion
    
    With .borders
      .LineStyle = xlContinuous
      .Weight = xlThin
      .ColorIndex = vbBlack
    End With
    
    .RowHeight = 27
    .Rows(1).Font.Bold = True
    .VerticalAlignment = xlCenter
    .IndentLevel = 1
    .EntireColumn.AutoFit
  
  End With
  
End Sub

Public Sub subSplitByRole(Ws As Worksheet)
Dim arrData() As Variant
Dim i As Integer
Dim strRole As String
Dim lngColour As Long
Dim rngColour As Range

  Ws.Activate
  
  Call subFormatSheet(Ws)
  
  arrData = Ws.Range("A1").CurrentRegion

  strRole = arrData(UBound(arrData), 4)
    
  For i = UBound(arrData) To 1 Step -1
  
    If arrData(i, 4) <> strRole Then
      Ws.Range("A" & i + 1).EntireRow.Insert
      With Ws.Range("A" & i + 1)
        With .Resize(1, 7)
          .Interior.Color = fncGetColour(strRole)
          .Merge
          With .borders
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = vbBlack
          End With
        End With
        .Value = strRole
        .Font.Bold = True
      End With
      strRole = arrData(i, 4)
    End If
  
  Next i

End Sub

Public Function fncGetColour(strRole As String) As Long
Dim rngColour As Range

  fncGetColour = 16777215

  Set rngColour = Worksheets("Role Colours").Range("A:A").Find(strRole, LookIn:=xlValues, LookAt:=xlWhole)
      
  If Not rngColour Is Nothing Then
  
    fncGetColour = rngColour.Interior.Color
          
  End If

End Function

Public Sub subCreateRoleColoursTab()
Dim Ws As Worksheet
Dim rng As Range

  If Not fncDoesWorksheetExist(ThisWorkbook, "Role Colours") Then

    Set Ws = fncCreateSheet(ThisWorkbook, "Role Colours")
  
    For Each rng In Ws.Range("A2:A6").Cells
      rng.Value = Choose(rng.Row - 1, "AMOR", "ASUP", "BATT", "HOST", "WAIT")
      rng.Interior.Color = Choose(rng.Row - 1, 7592334, 65535, 49407, 14524132, 14791492)
    Next rng
    
    Ws.Range("A1").Value = "Role"
    
    Call subFormatSheet(Ws)
    
  End If
  
End Sub

Private Function fncCreateSheet(Wb As Workbook, strWorksheet As String) As Worksheet

  Application.DisplayAlerts = False
  On Error Resume Next
  Wb.Worksheets(strWorksheet).Delete
  On Error GoTo 0
  Application.DisplayAlerts = True
  
  Wb.Sheets.Add after:=Wb.Sheets(Wb.Sheets.Count)

  ActiveSheet.Name = strWorksheet
  
  Set fncCreateSheet = ActiveSheet

End Function

Public Function fncDoesWorksheetExist(Wb As Workbook, strWorksheet As String) As Boolean
Dim Ws As Worksheet

  For Each Ws In Wb.Worksheets
    If Ws.Name = strWorksheet Then
      fncDoesWorksheetExist = True
    End If
  Next Ws
  
End Function
 
Upvote 0
Hi Lara

Here is the next version.

If I was you, I would create a new workbook and paste this code into a main code module. This is the best way to test it.

Copy the source data worksheet into this workbook and call it ‘Structured’ although we can change the name later.

Run the ‘subImportAndSplitData’ procedure.

A separate formatted sheet is created for each date in the ‘Structured’ worksheet.

It creates a worksheet name ‘Role Colours’ which contains the colours to use for each Role. I’m not sure if what you posted was just an example of what you wanted or the actual colours. Change the background colours for each Role on this sheet and these will be used for each result sheet when you next run the code. The ‘Role Colours’ worksheet will only be created if it does not already exist.

Do you have more Roles than the ones that I know about?

There are several procedures in the module that you may find useful in the future.

Let me know if it works as you want it to or if you need

VBA Code:
Option Explicit

Public Sub subImportAndSplitData()
Dim i As Integer
Dim WsData As Worksheet
Dim arrData() As Variant
Dim arrDate() As String
Dim rngLoc As Range
 
  ActiveWorkbook.Save
 
  Call subCreateRoleColoursTab
 
  Set WsData = Worksheets("Structured")
 
  WsData.Columns("D").Replace What:="SUP", Replacement:="ASUP", SearchOrder:=xlByRows, MatchCase:=True
 
  arrData = WsData.UsedRange
 
  For i = LBound(arrData) To UBound(arrData)
   
    If arrData(i, 1) = "Loc" Then
   
      Set rngLoc = WsData.Range("A" & i)
     
      With rngLoc
     
        arrDate = Split(.Offset(-4, 0).Value, " ")
   
        Call subCreateWorksheets(rngLoc, arrDate(1) & " " & arrDate(2))
     
      End With
           
    End If
   
  Next i
 
  MsgBox "Data has been processed and separate sheets been created.", vbOKOnly, "Confirmation"

End Sub

Private Sub subCreateWorksheets(rng As Range, strWorksheetName As String)
Dim Ws As Worksheet
            
  Set Ws = fncCreateSheet(ActiveWorkbook, strWorksheetName)
        
  With rng.CurrentRegion
    Ws.Range("A1").Formula2 = "=CHOOSECOLS(VSTACK(TAKE('" & .Parent.Name & "'!" & .Address & ",1),SORT(" & _
    "'" & .Parent.Name & "'!" & .Offset(1, 0).Resize(.Rows.Count - 1.7).Address & ",{4,5,6})),6,5,7,4,2,3,1)"
  End With
       
  With Ws.Range("A1").CurrentRegion
    .Value = .Value
    .Columns("E:F").NumberFormat = "HH:MM"
  End With
 
  Call subSplitByRole(Ws)
 
End Sub

Private Sub subFormatSheet(Ws As Worksheet)

  With Ws.Range("A1").CurrentRegion
   
    With .borders
      .LineStyle = xlContinuous
      .Weight = xlThin
      .ColorIndex = vbBlack
    End With
   
    .RowHeight = 27
    .Rows(1).Font.Bold = True
    .VerticalAlignment = xlCenter
    .IndentLevel = 1
    .EntireColumn.AutoFit
 
  End With
 
End Sub

Public Sub subSplitByRole(Ws As Worksheet)
Dim arrData() As Variant
Dim i As Integer
Dim strRole As String
Dim lngColour As Long
Dim rngColour As Range

  Ws.Activate
 
  Call subFormatSheet(Ws)
 
  arrData = Ws.Range("A1").CurrentRegion

  strRole = arrData(UBound(arrData), 4)
   
  For i = UBound(arrData) To 1 Step -1
 
    If arrData(i, 4) <> strRole Then
      Ws.Range("A" & i + 1).EntireRow.Insert
      With Ws.Range("A" & i + 1)
        With .Resize(1, 7)
          .Interior.Color = fncGetColour(strRole)
          .Merge
          With .borders
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = vbBlack
          End With
        End With
        .Value = strRole
        .Font.Bold = True
      End With
      strRole = arrData(i, 4)
    End If
 
  Next i

End Sub

Public Function fncGetColour(strRole As String) As Long
Dim rngColour As Range

  fncGetColour = 16777215

  Set rngColour = Worksheets("Role Colours").Range("A:A").Find(strRole, LookIn:=xlValues, LookAt:=xlWhole)
     
  If Not rngColour Is Nothing Then
 
    fncGetColour = rngColour.Interior.Color
         
  End If

End Function

Public Sub subCreateRoleColoursTab()
Dim Ws As Worksheet
Dim rng As Range

  If Not fncDoesWorksheetExist(ThisWorkbook, "Role Colours") Then

    Set Ws = fncCreateSheet(ThisWorkbook, "Role Colours")
 
    For Each rng In Ws.Range("A2:A6").Cells
      rng.Value = Choose(rng.Row - 1, "AMOR", "ASUP", "BATT", "HOST", "WAIT")
      rng.Interior.Color = Choose(rng.Row - 1, 7592334, 65535, 49407, 14524132, 14791492)
    Next rng
   
    Ws.Range("A1").Value = "Role"
   
    Call subFormatSheet(Ws)
   
  End If
 
End Sub

Private Function fncCreateSheet(Wb As Workbook, strWorksheet As String) As Worksheet

  Application.DisplayAlerts = False
  On Error Resume Next
  Wb.Worksheets(strWorksheet).Delete
  On Error GoTo 0
  Application.DisplayAlerts = True
 
  Wb.Sheets.Add after:=Wb.Sheets(Wb.Sheets.Count)

  ActiveSheet.Name = strWorksheet
 
  Set fncCreateSheet = ActiveSheet

End Function

Public Function fncDoesWorksheetExist(Wb As Workbook, strWorksheet As String) As Boolean
Dim Ws As Worksheet

  For Each Ws In Wb.Worksheets
    If Ws.Name = strWorksheet Then
      fncDoesWorksheetExist = True
    End If
  Next Ws
 
End Function
Dear High and Wilder :)

Thank you so much for your help!

So, I took your advice and did some testing in a blank work book. The code works as expected, looping through the CreateRoleColoursTab, DoesWorksheetExist and FncCreateSheet.

The only issue is that when it is going through the FncCreateSheet and hits

ActiveSheet.Name = strWorksheet

it changes the Structured Tab to the name Role Colours rather than creating a new one.

It then goes on to start creating the role colours tab at the top of the main sheet, but then obviously later when the data tries to sort, it throws an error as can no longer locate the Structured tab.

Error appears once it reaches : Set WsData = Worksheets("Structured")

I tried to look through and see why it does not create a new tab and think that maybe the error is in the fncCreateSheet as it is converting the active sheet rather than creating a new one. Set fncCreateSheet = ActiveSheet

Are you able to help me amend this part?

Also, like how you changed AMGR to AMOR <3<3<3<3

Lara x
 

Attachments

  • RoleColours.JPG
    RoleColours.JPG
    227.3 KB · Views: 1
Upvote 0
Just t
Dear High and Wilder :)

Thank you so much for your help!

So, I took your advice and did some testing in a blank work book. The code works as expected, looping through the CreateRoleColoursTab, DoesWorksheetExist and FncCreateSheet.

The only issue is that when it is going through the FncCreateSheet and hits

ActiveSheet.Name = strWorksheet

it changes the Structured Tab to the name Role Colours rather than creating a new one.

It then goes on to start creating the role colours tab at the top of the main sheet, but then obviously later when the data tries to sort, it throws an error as can no longer locate the Structured tab.

Error appears once it reaches : Set WsData = Worksheets("Structured")

I tried to look through and see why it does not create a new tab and think that maybe the error is in the fncCreateSheet as it is converting the active sheet rather than creating a new one. Set fncCreateSheet = ActiveSheet

Are you able to help me amend this part?

Also, like how you changed AMGR to AMOR <3<3<3<3

Lara x
**Just to let you know, once I hit that error and I manually change the name back to Structured and Then create the Role Colours tab, then continue to run the code, IT WORKS BEAUTIFULLY!! INCREDIBLE!! (See attached)

If you can help me fix that one thing with the sheet creation :)

It also shows one type mismatch error once it reaches Oct 12th, I wonder if this is because the location is different to the other days? Loc is still there though so could not work out why it throws the error.

To answer your question from before, no that is all the roles!

Thanks High and Wilder!! I think I need to contract you!

Lara x
 

Attachments

  • beautiful code!.JPG
    beautiful code!.JPG
    93.4 KB · Views: 2
  • Oct 12th error.JPG
    Oct 12th error.JPG
    171.2 KB · Views: 2
Upvote 0
Just t

**Just to let you know, once I hit that error and I manually change the name back to Structured and Then create the Role Colours tab, then continue to run the code, IT WORKS BEAUTIFULLY!! INCREDIBLE!! (See attached)

If you can help me fix that one thing with the sheet creation :)

It also shows one type mismatch error once it reaches Oct 12th, I wonder if this is because the location is different to the other days? Loc is still there though so could not work out why it throws the error.

To answer your question from before, no that is all the roles!

Thanks High and Wilder!! I think I need to contract you!

Lara x
Hi Lara

I'm not sure what is happening there. I tried to create the problem and I can't.

Now that you have your 'Role Colours' worksheet you can comment out this line

' Call subCreateRoleColoursTab

Also replace this line
WsData.Columns("D").Replace What:="SUP", Replacement:="ASUP", SearchOrder:=xlByRows, MatchCase:=True
with this one.
WsData.Columns("D").Replace What:="SUP", Replacement:="ASUP", SearchOrder:=xlByRows, LookAt:=xlWhole, MatchCase:=True

The new line replaces SUP with ASUP and not ASUP with AASUP, a danger if you run the process more than once without
replacing the data in the 'Structured' worksheet.

Can you then test the code again.

The problem with October 12th is weird.

Can you post the data in the 'Structured' sheet or at least the data for October 12th using XL2BB.

XL2BB - Excel Range to BBCode

Regarding your comment:
Also, like how you changed AMGR to AMOR

Was it this replacement that was needed or 'SUP' to 'ASUP'?
 
Upvote 0
752 testing Oct 2nd.xlsx
ABCDEFG
1Duty Sheet
2
3Monday, 07 October 2024
4
5~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
6
7LocStartEndRolePayroll #Employee NameClass
8MarketCoFOH15:0023:30AMGR391658MCQUADE, LaraSA
9MarketCoFOH16:0022:00BATT404558ELANGBAM, SophiaPT 2
10MarketCoFOH16:0022:00WAIT435250WAHYUNI, GustiPT 2
11MarketCoFOH17:0021:00WAIT409708PUYOD, JackiePT 3
12MarketCoFOH17:0021:00WAIT436269JIANG, JackiePT 2
13MarketCoFOH17:0023:00HOST354130ELLISON, TraceyPT 4
14MarketCoFOH17:3021:30WAIT435775VALBUENA CORDOBA, CindyPT 2
15MarketCoFOH18:0022:00WAIT434750STITI, Nanda Giri AyuPT 2
16
17Duty Sheet
18
19Tuesday, 08 October 2024
20
21~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
22
23LocStartEndRolePayroll #Employee NameClass
24MarketCoFOH15:0023:30AMGR391658MCQUADE, LaraSA
25MarketCoFOH16:0022:00BATT390034WOOD, SimonPT 2
26MarketCoFOH16:0022:00WAIT435250WAHYUNI, GustiPT 2
27MarketCoFOH17:0021:00WAIT436269JIANG, JackiePT 2
28MarketCoFOH17:0021:00WAIT435490LI, HaoPT 1
29MarketCoFOH17:0023:00HOST432682COSMAS, SamanthaPT 2
30MarketCoFOH17:3021:30WAIT435775VALBUENA CORDOBA, CindyPT 2
31MarketCoFOH18:0022:00WAIT434750STITI, Nanda Giri AyuPT 2
32MarketCoFOH18:0022:00WAIT417890TRAN, KellyPT 2
33
34Duty Sheet
35
36Wednesday, 09 October 2024
37
38~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
39
40LocStartEndRolePayroll #Employee NameClass
41MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
42MarketCoFOH16:0022:00BATT436299YEBOAH, NayaPT 2
43CPP-RSFOHWait16:0022:00WAIT365459BATIZAT, NataliyaPT 3
44MarketCoFOH17:0021:00WAIT425016GIRALDO FRANCO, DianaPT 1
45MarketCoFOH17:0021:00WAIT423824INDRA, DiniPT 1
46MarketCoFOH17:0023:00HOST427646PARK, HaeunPT 1
47MarketCoFOH17:3021:30WAIT420352MOON, Soonhong (Moon)PT 1
48MarketCoFOH18:0022:00WAIT435250WAHYUNI, GustiPT 2
49
50Duty Sheet
51
52Thursday, 10 October 2024
53
54~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
55
56LocStartEndRolePayroll #Employee NameClass
57MarketCoFOH12:0020:30AMGR391658MCQUADE, LaraSA
58MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
59MarketCoFOH16:0022:00BATT434166KANDEL, SunitaPT 2
60CPP-RSFOHWait16:0022:00WAIT365459BATIZAT, NataliyaPT 3
61MarketCoFOH16:3021:30WAIT409708PUYOD, JackiePT 3
62MarketCoFOH17:0022:00WAIT300008ARTHURS, AndrewPT 3
63MarketCoFOH17:0023:00HOST434139TAMANG, ShantiPT 2
64MarketCoFOH17:3021:30WAIT436269JIANG, JackiePT 2
65MarketCoFOH18:0022:00WAIT432773JONG, PatrickPT 1
66
67Duty Sheet
68
69Friday, 11 October 2024
70
71~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
72
73LocStartEndRolePayroll #Employee NameClass
74MarketCoFOH12:0020:30AMGR391658MCQUADE, LaraSA
75MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
76MarketCoFOH16:0022:00BATT404558ELANGBAM, SophiaPT 2
77MarketCoFOH16:0022:00WAIT300008ARTHURS, AndrewPT 3
78CPP-RSFOHWait16:0022:00WAIT365459BATIZAT, NataliyaPT 3
79MarketCoFOH16:0023:30HOST354130ELLISON, TraceyPT 4
80MarketCoFOH16:3021:30WAIT409708PUYOD, JackiePT 3
81MarketCoFOH17:0022:00BATT390034WOOD, SimonPT 2
82MarketCoFOH17:0022:00BATT436299YEBOAH, NayaPT 2
83MarketCoFOH17:0022:00WAIT425016GIRALDO FRANCO, DianaPT 1
84MarketCoFOH17:0022:00WAIT423824INDRA, DiniPT 1
85MarketCoFOH17:0022:00WAIT435490LI, HaoPT 1
86MarketCoFOH17:0023:00HOST422611CROOK, LucyPT 1
87MarketCoFOH18:0022:00WAIT435775VALBUENA CORDOBA, CindyPT 2
88MarketCoFOH18:0022:00WAIT435250WAHYUNI, GustiPT 2
89
90Duty Sheet
91
92Saturday, 12 October 2024
93
94~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
95
96LocStartEndRolePayroll #Employee NameClass
97CPP-RSFOHWait05:3014:00WAIT362076MAGALONG, JocelynPT 2
98MarketCoFOH06:0015:00BATT434759DORJI, TshewangPT 2
99MarketCoFOH06:3012:30HOST417890TRAN, KellyPT 2
100MarketCoFOH06:3012:30WAIT426601SAPKOTA, PragyaPT 2
101MarketCoFOH06:3014:00BATT434139TAMANG, ShantiPT 2
102MarketCoFOH08:0014:00WAIT434133SEKARINI, SekarPT 2
103MarketCoFOH08:3014:30BATT352199GUNAWAN, AileenPT 1
104MarketCoFOH10:0015:00WAIT435775VALBUENA CORDOBA, CindyPT 2
105CPP-RSFOHWait11:0016:00WAIT365459BATIZAT, NataliyaPT 3
106MarketCoFOH12:0020:30AMGR391658MCQUADE, LaraSA
107MarketCoFOH14:3022:00BATT390034WOOD, SimonPT 2
108MarketCoFOH15:0023:30HOST354130ELLISON, TraceyPT 4
109MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
110MarketCoFOH16:3020:30BATT352199GUNAWAN, AileenPT 1
111MarketCoFOH16:3021:30WAIT409708PUYOD, JackiePT 3
112MarketCoFOH17:0022:00BATT436299YEBOAH, NayaPT 2
113MarketCoFOH17:0022:00WAIT300008ARTHURS, AndrewPT 3
114CPP-RSFOHWait17:0022:00WAIT365459BATIZAT, NataliyaPT 3
115CPP-RSFOHWait17:0022:00WAIT408281HANDI, HandiPT 2
116MarketCoFOH17:0023:00HOST427646PARK, HaeunPT 1
117MarketCoFOH17:3022:30WAIT434750STITI, Nanda Giri AyuPT 2
118MarketCoFOH17:3022:30WAIT435250WAHYUNI, GustiPT 2
119MarketCoFOH17:3022:30WAIT423824INDRA, DiniPT 1
120MarketCoFOH17:3022:30WAIT420352MOON, Soonhong (Moon)PT 1
121MarketCoFOH18:0022:00WAIT432773JONG, PatrickPT 1
122
123Duty Sheet
124
125Sunday, 13 October 2024
126
127~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
128
129LocStartEndRolePayroll #Employee NameClass
130CPP-RSFOHWait05:3014:00WAIT362076MAGALONG, JocelynPT 2
131MarketCoFOH06:0015:00BATT434759DORJI, TshewangPT 2
132MarketCoFOH06:3011:00HOST432682COSMAS, SamanthaPT 2
133MarketCoFOH06:3011:30HOST417890TRAN, KellyPT 2
134MarketCoFOH06:3012:30BATT400348CHEON, LaurenPT 2
135MarketCoFOH06:3012:30WAIT426601SAPKOTA, PragyaPT 2
136MarketCoFOH08:0014:00BATT434139TAMANG, ShantiPT 2
137MarketCoFOH08:0014:00WAIT434133SEKARINI, SekarPT 2
138MarketCoFOH10:0015:00WAIT434750STITI, Nanda Giri AyuPT 2
139MarketCoFOH12:0020:30AMGR391658MCQUADE, LaraSA
140MarketCoFOH14:0020:00BATT390034WOOD, SimonPT 2
141CPP-RSFOHWait14:0022:00WAIT365459BATIZAT, NataliyaPT 3
142MarketCoFOH15:0021:00HOST354130ELLISON, TraceyPT 4
143MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
144MarketCoFOH16:0022:00BATT404558ELANGBAM, SophiaPT 2
145MarketCoFOH17:0022:00WAIT300008ARTHURS, AndrewPT 3
146MarketCoFOH17:0022:00WAIT409708PUYOD, JackiePT 3
147CPP-RSFOHWait17:0022:00WAIT408281HANDI, HandiPT 2
148MarketCoFOH17:0023:00HOST427646PARK, HaeunPT 1
149MarketCoFOH17:3022:30BATT352199GUNAWAN, AileenPT 1
150MarketCoFOH17:3022:30WAIT435775VALBUENA CORDOBA, CindyPT 2
151MarketCoFOH17:3022:30WAIT435250WAHYUNI, GustiPT 2
152MarketCoFOH18:0022:00WAIT425016GIRALDO FRANCO, DianaPT 1
153MarketCoFOH18:0022:00WAIT432773JONG, PatrickPT 1
154
155Duty Sheet
156
157Monday, 14 October 2024
158
159~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
160
161LocStartEndRolePayroll #Employee NameClass
162MarketCoFOH15:0023:30SUP434759DORJI, TshewangPT 2
163MarketCoFOH16:0022:00BATT404558ELANGBAM, SophiaPT 2
164CPP-RSFOHWait16:0022:00WAIT426601SAPKOTA, PragyaPT 2
165MarketCoFOH17:0022:00BATT434166KANDEL, SunitaPT 2
166MarketCoFOH17:0022:00WAIT409708PUYOD, JackiePT 3
167MarketCoFOH17:0022:00WAIT436269JIANG, JackiePT 2
168MarketCoFOH17:0023:00HOST354130ELLISON, TraceyPT 4
169MarketCoFOH17:3022:30WAIT435775VALBUENA CORDOBA, CindyPT 2
170MarketCoFOH18:0022:00WAIT432773JONG, PatrickPT 1
171MarketCoFOH18:0022:00WAIT420352MOON, Soonhong (Moon)PT 1
172
173Duty Sheet
174
175Tuesday, 15 October 2024
176
177~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
178
179LocStartEndRolePayroll #Employee NameClass
180MarketCoFOH15:0023:30AMGR391658MCQUADE, LaraSA
181MarketCoFOH16:0022:00BATT390034WOOD, SimonPT 2
182CPP-RSFOHWait16:0022:00WAIT426601SAPKOTA, PragyaPT 2
183MarketCoFOH17:0022:00WAIT436269JIANG, JackiePT 2
184MarketCoFOH17:0022:00WAIT435250WAHYUNI, GustiPT 2
185MarketCoFOH17:0023:00HOST432682COSMAS, SamanthaPT 2
186MarketCoFOH17:3022:30WAIT435775VALBUENA CORDOBA, CindyPT 2
187MarketCoFOH18:0022:00WAIT434750STITI, Nanda Giri AyuPT 2
188
189Duty Sheet
190
191Wednesday, 16 October 2024
192
193~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
194
195LocStartEndRolePayroll #Employee NameClass
196MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
197MarketCoFOH16:0022:00BATT436299YEBOAH, NayaPT 2
198CPP-RSFOHWait16:0022:00WAIT365459BATIZAT, NataliyaPT 3
199MarketCoFOH17:0022:00WAIT300008ARTHURS, AndrewPT 3
200MarketCoFOH17:0022:00WAIT420352MOON, Soonhong (Moon)PT 1
201MarketCoFOH17:0023:00HOST427646PARK, HaeunPT 1
202MarketCoFOH17:3022:30WAIT436269JIANG, JackiePT 2
203MarketCoFOH18:0022:00WAIT434750STITI, Nanda Giri AyuPT 2
204
205Duty Sheet
206
207Thursday, 17 October 2024
208
209~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
210
211LocStartEndRolePayroll #Employee NameClass
212MarketCoFOH13:0021:30AMGR391658MCQUADE, LaraSA
213MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
214MarketCoFOH16:0022:00BATT434166KANDEL, SunitaPT 2
215MarketCoFOH16:0022:00WAIT300008ARTHURS, AndrewPT 3
216CPP-RSFOHWait16:0022:00WAIT365459BATIZAT, NataliyaPT 3
217MarketCoFOH17:0022:00WAIT409708PUYOD, JackiePT 3
218MarketCoFOH17:0023:00HOST434139TAMANG, ShantiPT 2
219MarketCoFOH18:0022:00WAIT425016GIRALDO FRANCO, DianaPT 1
220MarketCoFOH18:0022:00WAIT423824INDRA, DiniPT 1
221
222Duty Sheet
223
224Friday, 18 October 2024
225
226~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
227
228LocStartEndRolePayroll #Employee NameClass
229MarketCoFOH15:0023:30HOST354130ELLISON, TraceyPT 4
230MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
231MarketCoFOH16:0022:00BATT390034WOOD, SimonPT 2
232MarketCoFOH16:0022:00WAIT300008ARTHURS, AndrewPT 3
233CPP-RSFOHWait16:0022:00WAIT365459BATIZAT, NataliyaPT 3
234MarketCoFOH16:0022:00WAIT409708PUYOD, JackiePT 3
235MarketCoFOH17:0022:00BATT436299YEBOAH, NayaPT 2
236MarketCoFOH17:0022:00WAIT425016GIRALDO FRANCO, DianaPT 1
237MarketCoFOH17:0022:00WAIT423824INDRA, DiniPT 1
238MarketCoFOH17:0023:00BATT404558ELANGBAM, SophiaPT 2
239MarketCoFOH17:0023:00HOST422611CROOK, LucyPT 1
240MarketCoFOH17:3022:30WAIT435775VALBUENA CORDOBA, CindyPT 2
241MarketCoFOH17:3022:30WAIT435490LI, HaoPT 1
242MarketCoFOH18:0022:00WAIT435250WAHYUNI, GustiPT 2
243
244Duty Sheet
245
246Saturday, 19 October 2024
247
248~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
249
250LocStartEndRolePayroll #Employee NameClass
251CPP-RSFOHWait05:3014:00WAIT362076MAGALONG, JocelynPT 2
252MarketCoFOH06:0015:00BATT434759DORJI, TshewangPT 2
253MarketCoFOH06:3011:00HOST432682COSMAS, SamanthaPT 2
254MarketCoFOH06:3012:30BATT400348CHEON, LaurenPT 2
255MarketCoFOH06:3012:30WAIT434133SEKARINI, SekarPT 2
256MarketCoFOH08:0014:00BATT434166KANDEL, SunitaPT 2
257MarketCoFOH08:0014:00WAIT426601SAPKOTA, PragyaPT 2
258MarketCoFOH10:0015:00WAIT434750STITI, Nanda Giri AyuPT 2
259CPP-RSFOHWait11:0016:00WAIT365459BATIZAT, NataliyaPT 3
260MarketCoFOH12:0020:30AMGR391658MCQUADE, LaraSA
261MarketCoFOH14:0022:00BATT436299YEBOAH, NayaPT 2
262MarketCoFOH15:0023:30HOST354130ELLISON, TraceyPT 4
263MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
264MarketCoFOH16:0022:00BATT390034WOOD, SimonPT 2
265MarketCoFOH16:3022:30WAIT300008ARTHURS, AndrewPT 3
266MarketCoFOH16:3022:30WAIT409708PUYOD, JackiePT 3
267CPP-RSFOHWait17:0022:00WAIT365459BATIZAT, NataliyaPT 3
268CPP-RSFOHWait17:0022:00WAIT408281HANDI, HandiPT 2
269MarketCoFOH17:0023:00BATT404558ELANGBAM, SophiaPT 2
270MarketCoFOH17:0023:00HOST422611CROOK, LucyPT 1
271MarketCoFOH17:3022:30WAIT435250WAHYUNI, GustiPT 2
272MarketCoFOH17:3022:30WAIT425016GIRALDO FRANCO, DianaPT 1
273MarketCoFOH17:3022:30WAIT435490LI, HaoPT 1
274MarketCoFOH18:0022:00WAIT432773JONG, PatrickPT 1
275MarketCoFOH18:0022:00WAIT420352MOON, Soonhong (Moon)PT 1
276
277Duty Sheet
278
279Sunday, 20 October 2024
280
281~ Duty/Shift Manager@ Human Resources$ Payroll* Scheduling^ Supervisor
282
283LocStartEndRolePayroll #Employee NameClass
284CPP-RSFOHWait05:3014:00WAIT362076MAGALONG, JocelynPT 2
285MarketCoFOH06:0015:00BATT434759DORJI, TshewangPT 2
286MarketCoFOH06:3011:30HOST417890TRAN, KellyPT 2
287MarketCoFOH06:3012:30BATT400348CHEON, LaurenPT 2
288MarketCoFOH06:3012:30WAIT434133SEKARINI, SekarPT 2
289MarketCoFOH08:0014:00BATT434166KANDEL, SunitaPT 2
290MarketCoFOH08:0014:00WAIT426601SAPKOTA, PragyaPT 2
291MarketCoFOH10:0015:00WAIT435775VALBUENA CORDOBA, CindyPT 2
292MarketCoFOH12:0020:30AMGR391658MCQUADE, LaraSA
293CPP-RSFOHWait14:0022:00WAIT365459BATIZAT, NataliyaPT 3
294MarketCoFOH15:0021:00HOST354130ELLISON, TraceyPT 4
295MarketCoFOH15:0023:30SUP429186GONZAL, JayPT 2
296MarketCoFOH16:0022:00BATT404558ELANGBAM, SophiaPT 2
297MarketCoFOH17:0022:00WAIT300008ARTHURS, AndrewPT 3
298MarketCoFOH17:0022:00WAIT409708PUYOD, JackiePT 3
299CPP-RSFOHWait17:0022:00WAIT408281HANDI, HandiPT 2
300MarketCoFOH17:0023:00HOST422611CROOK, LucyPT 1
301MarketCoFOH17:3021:30WAIT435250WAHYUNI, GustiPT 2
302MarketCoFOH17:3021:30WAIT420352MOON, Soonhong (Moon)PT 1
303MarketCoFOH18:0022:00WAIT425016GIRALDO FRANCO, DianaPT 1
Structured
 
Upvote 0
Hi Lara

I'm not sure what is happening there. I tried to create the problem and I can't.

Now that you have your 'Role Colours' worksheet you can comment out this line

' Call subCreateRoleColoursTab

Also replace this line
WsData.Columns("D").Replace What:="SUP", Replacement:="ASUP", SearchOrder:=xlByRows, MatchCase:=True
with this one.
WsData.Columns("D").Replace What:="SUP", Replacement:="ASUP", SearchOrder:=xlByRows, LookAt:=xlWhole, MatchCase:=True

The new line replaces SUP with ASUP and not ASUP with AASUP, a danger if you run the process more than once without
replacing the data in the 'Structured' worksheet.

Can you then test the code again.

The problem with October 12th is weird.

Can you post the data in the 'Structured' sheet or at least the data for October 12th using XL2BB.

XL2BB - Excel Range to BBCode

Regarding your comment:
Also, like how you changed AMGR to AMOR

Was it this replacement that was needed or 'SUP' to 'ASUP'?
Dear High & Wilder :)

I made the edits as suggested, and create the Role Colours tab and IT WORKS PERFECTLY!!! HOW CAN I EVER REPAY YOU!!

thank you thank you thank you!!!

Don´t worry I was just making a joke about AMOR ( It means love in spanish!)

Honestly, I can´t thank you enough!

Laraxxxxxxxx
 
Upvote 0
Dear High & Wilder :)

I made the edits as suggested, and create the Role Colours tab and IT WORKS PERFECTLY!!! HOW CAN I EVER REPAY YOU!!

thank you thank you thank you!!!

Don´t worry I was just making a joke about AMOR ( It means love in spanish!)

Honestly, I can´t thank you enough!

Laraxxxxxxxx
Does it still hiccup on 12th October?

I will test it using your data.
 
Upvote 0
Dear High & Wilder :)

I made the edits as suggested, and create the Role Colours tab and IT WORKS PERFECTLY!!! HOW CAN I EVER REPAY YOU!!

thank you thank you thank you!!!

Don´t worry I was just making a joke about AMOR ( It means love in spanish!)

Honestly, I can´t thank you enough!

Laraxxxxxxxx
At some stage when putting some sample data together I misread AMGR for AMOR. :)

I used your data and it worked fine even creating the 'Role Colours' worksheet.

Do you have any more jobs for me?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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