I have a macro that allows me to generate worksheets based on a range of cells, however if the range includes a duplicate it throws an error.
I also need to solve the problem of adding new data to the range and allowing the macro to skip over cells where a worksheet already exists and only create new worksheets for new and unique cells content.
Any ideas would be helpful.
Here is the current Macro and I am attaching a sample.
Sub Generate_worksheets()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Worksheets("Master")
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("Select").Range("A5")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
Sheets("Master").Visible = True
Sheets("End").Visible = False
For Each MyCell In MyRange
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
ThisWorkbook.Worksheets("Master (2)").Name = MyCell.Value
With ActiveSheet
.Range("B3").Value = .Name
End With
Next MyCell
Sheets("Master").Visible = False
Sheets("End").Visible = True
MsgBox "Done!"
End Sub
Thanks in advance,
Matt
Bookmarks