PDA

View Full Version : Help Understanding Code Dealing with Creating New Spreadsheets



yerromnitsuj
09-12-2011, 09:30 AM
I'm trying to decipher a portion of code. The workbook already has a sheet X. When the code gets to this point it creates a new sheet called X and I get an error stating that I can't name a new sheet the same name as an existing sheet. Can someone help me to understand what this code seems to be trying to do and why i might be getting that error? Thanks!

For i = 1 To Worksheets(SheetA).Range("B3").Value

Sheets("X").Select
Sheets("X").Copy After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Worksheets(SheetB).Cells(i + 1, 1)

Bob Phillips
09-12-2011, 10:10 AM
I think it will only fail if the values in column A are duplicated.

BTW, selecting sheet X is unnecessary.