Hi Swapijs
This code includes the "N1" or "N2" column Populate
Option Explicit
Function getSheetWithDefault(name As String, Optional wb As Excel.Workbook) As Excel.Worksheet
If wb Is Nothing Then
Set wb = ThisWorkbook
End If
If Not sheetExists(name, wb) Then
wb.Worksheets.Add(After:=wb.Worksheets(wb.Worksheets.Count)).name = name
End If
Set getSheetWithDefault = wb.Sheets(name)
End Function
Function sheetExists(name As String, Optional wb As Excel.Workbook) As Boolean
Dim sheet As Excel.Worksheet
If wb Is Nothing Then
Set wb = ThisWorkbook
End If
sheetExists = False
For Each sheet In wb.Worksheets
If sheet.name = name Then
sheetExists = True
Exit Function
End If
Next sheet
End Function
Sub CreateSheets()
Dim MyCell As Range
Dim MyRange As Range
Dim ws As Worksheet
Set MyRange = Sheets("Sheet1").Range("A2")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
For Each MyCell In MyRange
If Sheets(Sheets.Count).name <> MyCell.Value Then
Set ws = getSheetWithDefault(MyCell.Value)
End If
'Calls Subroutine to populate
Next MyCell
Call CopyInfo
End Sub
Option Explicit
Sub CopyInfo()
Dim wkSht As Worksheet
Dim cell As Range
Dim nextRow As Long
Dim lRow As Long
Dim i As Integer
Dim celltxt As String
Dim celltxtval As String
lRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
For Each wkSht In Sheets
Sheets("Sheet1").Activate
For i = 2 To lRow
celltxt = Sheets("Sheet1").Range("F" & i)
If Sheets("Sheet1").Range("A" & i).Value = wkSht.name Then
Sheets("Sheet1").Activate
With Sheets("Sheet1")
If LCase(InStr(1, celltxt, "Next business day")) Then
celltxtval = "N2"
Else
If LCase(InStr(1, celltxt, "Same business day")) Then
celltxtval = "N1"
End If
End If
End With
wkSht.Activate
nextRow = wkSht.Range("A" & Rows.Count).End(xlUp).Row + 1
Sheets("Sheet1").Range("A" & i).EntireRow.Copy Destination:=wkSht.Range("A" & nextRow)
wkSht.Range("L" & nextRow) = celltxtval
End If
Next i
Next wkSht
Application.ScreenUpdating = True
End Sub
I have no time to add the other code...will do so soonest.
Bookmarks