Consulting

Results 1 to 2 of 2

Thread: Help Understanding Code Dealing with Creating New Spreadsheets

  1. #1

    Help Understanding Code Dealing with Creating New Spreadsheets

    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)
    Last edited by yerromnitsuj; 09-12-2011 at 09:53 AM.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    I think it will only fail if the values in column A are duplicated.

    BTW, selecting sheet X is unnecessary.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •