I'm new to vba macros, so I need this macro to run for a list of names and add each name once after a worksheet has been created. The problem comes in when I have to add the name "Fantino; Alessandro & Gian Natale" is over 31 characters long the limit by which excel put into naming worksheets and I'm stuck on how to get around this problem for awhile now. The background to this is in my excel worksheet I have 6 column, column 3 is my names and I want to copy all that data across to each of the active worksheets.
Here is the vba code:
Sub AddSheets()
Dim producerName As String
Dim rowCounter As Integer
Dim outputRow As Integer
Dim headCounter As Integer
headCounter = 1
rowCounter = 2
Do
producerName = Sheets("List").Cells(Left(rowCounter, 31), 3)
If producerName <> "" Then
On Error Resume Next
If (Sheets(producerName).Name = "") Then
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = producerName
outputRow = 2
Sheets("List").Range(Sheets("List").Cells(headCounter, 1), Sheets("List").Cells(headCounter, 6)).Copy
Sheets(producerName).Range(Sheets(producerName).Cells(headCounter, 1), Sheets(producerName).Cells(headCounter, 6)).PasteSpecial
End If
Sheets("List").Range(Sheets("List").Cells(rowCounter, 1), Sheets("List").Cells(rowCounter, 6)).Copy
Sheets(producerName).Range(Sheets(producerName).Cells(outputRow, 1), Sheets(producerName).Cells(outputRow, 6)).PasteSpecial
rowCounter = rowCounter + 1
outputRow = outputRow + 1
End If
Loop Until producerName = ""
End Sub
Please help me
Jun
Bookmarks