Option Explicit
Sub CreateSheetsFromAList()
Dim Cel As Range, Rng As Range
Dim Clients As Range, CollectionClients As Range, InterestClients As Range
Dim ClientName As String
Dim ClientShtTemplate As Worksheet
Dim NewClientSht As Worksheet 'Demonstrate three ways
Dim InterestSht As Worksheet 'Second way
Dim CollectionsSht 'Third way
Dim CollectionDates As Range
Dim ClientsCollectionDates As Range
Set CollectionsSht = Worksheets("Collections")
Set InterestSht = Worksheets("Interest")
Set ClientShtTemplate = Worksheets("Clients")
''''Set Ranges
With InterestSht
Set InterestClients = Range(.Range("A5"), .Cells(Rows.Count, "A").End(xlUp))
End With
With CollectionsSht
Set CollectionClients = Range(.Range("D10"), .Cells(10, Columns.Count).End(xlToLeft))
Set CollectionDates = Range(.Range("A10"), .Cells(.Rows.Count, "A").End(xlUp))
End With
''''Create Sheets for all Clients
'''''''''''''''''''''''''''''
''''Create new Client Sheet
For Each Cel In InterestClients
If Trim(Cel.Value) <> "" Then
If Not SheetExists(Cel.Value) Then
Sheets.Add After:=Sheets(Sheets.Count)
Set NewClientSht = Sheets(Sheets.Count)
''''Fill new Client Sheet
With NewClientSht
.Name = Cel.Value
ClientShtTemplate.Cells.Copy
.Paste
.Range("B6") = .Name
ClientName = .Name
Set ClientsCollectionDates = Range(.Range("B10"), Cells(Rows.Count, "B").End(xlUp))
End With
''''I am lost at this point. I have commented it to show what it tells me.
If ClientName = CollectionClients.Value Then 'Counter moves right until end of row (last column)
'If String Variable = Large Range Then 'Say What? What counter?
If CollectionDates = ClientsCollectionDates Then 'checks if date on collection sheet same as client worksheet
'This is possible if every cell in one range = every cell in the other
CollectionsSht.Range("D10").Offset(0, 3).End(xlToLeft).Column.Copy
'Almost says copy the the column of first used Cell in Row 10. (the left of) Range("G10")
NewClientSht.Range("C10").Paste
'Paste that entire copied Column below ("C10")
End If
CollectionsSht.Range("D10").Offset(1, 0).Select 'move one row down and repeat the condition above
'on every loop, select Range("D11"). Why?
End If
End If
End If
Next Cel
End Sub
Edit to Add: now I come back and see that the ranges in your code do not match the ranges in your text.
Bookmarks