Results 1 to 9 of 9

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

Threaded View

  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


    Sub jaktokvrwa()
    
       Dim TheNewWB As Workbook
        Set TheNewWB = Workbooks.Add
    
        ThisWorkbook. _
            Activate
        Sheets("A").Select
        Cells.Select
        Selection.Copy
        Workbooks.Add
        ActiveSheet.Paste
        ThisWorkbook. _
            Activate
        Sheets("B").Select
        Cells.Select
        Application.CutCopyMode = False
        Selection.Copy
        TheNewWB.Activate
        Sheets("Sheet2").Select
        Cells.Select
        ActiveSheet.Paste
        ThisWorkbook. _
            Activate
        Sheets("C").Select
        Cells.Select
        Application.CutCopyMode = False
        Selection.Copy
        TheNewWB.Activate
        Sheets("Sheet3").Select
        Cells.Select
        ActiveSheet.Paste
        Sheets.Add After:=Sheets(Sheets.Count)
        Sheets.Add After:=Sheets(Sheets.Count)
        Sheets.Add After:=Sheets(Sheets.Count)
        ThisWorkbook. _
            Activate
        Sheets("D").Select
        Range("Table24[#All]").Select
        Application.CutCopyMode = False
        Selection.Copy
        TheNewWB.Activate
        Sheets("Sheet4").Select
        ActiveSheet.Paste
        ThisWorkbook. _
            Activate
        Sheets("E").Select
        Cells.Select
        Application.CutCopyMode = False
        Selection.Copy
        TheNewWB.Activate
        Sheets("Sheet5").Select
        Cells.Select
        ActiveSheet.Paste
        ThisWorkbook. _
            Activate
        Sheets("F").Select
        Range("C1:CC3").Select
        Application.CutCopyMode = False
        Selection.Copy
        TheNewWB.Activate
        Sheets("Sheet6").Select
        Range("C1").Select
        ActiveSheet.Paste
        ThisWorkbook. _
            Activate
        Range("Table1[#All]").Select
        Application.CutCopyMode = False
        Selection.Copy
        TheNewWB.Activate
        Range("A4").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
    
    End Sub
    Thank you in advance for your help.
    Last edited by Vogelmann; 10-18-2012 at 08:33 AM.

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