+ Reply to Thread
Results 1 to 9 of 9

why excel creates two new worksheets instead of one using this code?

  1. #1
    Registered User
    Join Date
    07-01-2012
    Location
    Tilburg, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    96

    why excel creates two new worksheets instead of one using this code?

    Hi all,

    Question is in the topic, instead of having one new workbooks with 6 sheets that contain the data from another workbook, it creates two - in the second one (say, Book2), sheet1, there is all data that is supposed to be in Sheet1 of Book1 (first newly created book). And Sheet1 in Book1 is empty...
    I went through the code and have no idea why, could you help me with that?
    Here is t


    Please Login or Register  to view this content.
    Thank you in advance for your help.
    Last edited by Vogelmann; 10-18-2012 at 08:33 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: why excel creates two new worksheets instead of one using this code?

    Excel doen't, you do:

    Please Login or Register  to view this content.



  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: why excel creates two new worksheets instead of one using this code?

    Your code can actually be written as -
    Please Login or Register  to view this content.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    07-01-2012
    Location
    Tilburg, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: why excel creates two new worksheets instead of one using this code?

    so which one should I delete to make `TheNewWB`still working? Second one? It`s strange by the way, because I used exactly the same code few days ago and it was fine (e.g. one workbook has been created).

  5. #5
    Registered User
    Join Date
    07-01-2012
    Location
    Tilburg, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: why excel creates two new worksheets instead of one using this code?

    arlu1201 this is just the part of a bigger macro and it doesn`t work properly when I change it in a way you proposed. Several errors appear while I replaced my old code by yours. So now I want to find/change just a single row or two, but I see the benefits of your code and I`m gonna use it later today when I will have more time. Now the most important thing is to fix the problem with two sheets.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: why excel creates two new worksheets instead of one using this code?

    Remove the 2nd Workbooks.add code line from your code. That will solve it.

  7. #7
    Registered User
    Join Date
    07-01-2012
    Location
    Tilburg, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: why excel creates two new worksheets instead of one using this code?

    that`s what I did, and now only but the code still did not paste the data from sheet A in original workbook to sheet1 in Book1. Do you know why?

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: why excel creates two new worksheets instead of one using this code?

    After
    Please Login or Register  to view this content.
    add
    Please Login or Register  to view this content.
    and then comes
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-01-2012
    Location
    Tilburg, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: why excel creates two new worksheets instead of one using this code?

    perfect, thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1