+ Reply to Thread
Results 1 to 5 of 5

copy spreadsheet in new workbook, macro problem

  1. #1
    matthias
    Guest

    copy spreadsheet in new workbook, macro problem

    hi if i run this macro,he copies the 2 spreadsheets as i want, but i
    want the 2 copied sheets in the same workbook!! can i do this???


    If ActiveWorkbook.Worksheets("sheet1").Range("A1") =
    ActiveWorkbook.Worksheets("sheet2").Range("A1") Then
    ActiveWorkbook.Worksheets("sheet1").Copy
    Cells.Copy
    Cells.PasteSpecial xlPasteValues
    Cells(1).Select
    Application.CutCopyMode = False

    ActiveWorkbook.Worksheets("sheet2").Copy
    Cells.Copy
    Cells.PasteSpecial xlPasteValues
    Cells(1).Select
    Application.CutCopyMode = False

    End If





    End Sub


  2. #2
    Tom Ogilvy
    Guest

    Re: copy spreadsheet in new workbook, macro problem

    If ActiveWorkbook.Worksheets("sheet1"). _
    Range("A1") = ActiveWorkbook.Worksheets( _
    "sheet2").Range("A1") Then
    ActiveWorkbook.Worksheets("sheet1").Copy _
    After:=Worksheets(Worksheets.count)
    Cells.Copy
    Cells.PasteSpecial xlPasteValues
    Cells(1).Select
    Application.CutCopyMode = False

    ActiveWorkbook.Worksheets("sheet2").Copy _
    After:=Worksheets(Worksheets.count)
    Cells.Copy
    Cells.PasteSpecial xlPasteValues
    Cells(1).Select
    Application.CutCopyMode = False

    End If

    --
    Regards,
    Tom Ogilvy

    "matthias" <[email protected]> wrote in message
    news:[email protected]...
    > hi if i run this macro,he copies the 2 spreadsheets as i want, but i
    > want the 2 copied sheets in the same workbook!! can i do this???
    >
    >
    > If ActiveWorkbook.Worksheets("sheet1").Range("A1") =
    > ActiveWorkbook.Worksheets("sheet2").Range("A1") Then
    > ActiveWorkbook.Worksheets("sheet1").Copy
    > Cells.Copy
    > Cells.PasteSpecial xlPasteValues
    > Cells(1).Select
    > Application.CutCopyMode = False
    >
    > ActiveWorkbook.Worksheets("sheet2").Copy
    > Cells.Copy
    > Cells.PasteSpecial xlPasteValues
    > Cells(1).Select
    > Application.CutCopyMode = False
    >
    > End If
    >
    >
    >
    >
    >
    > End Sub
    >




  3. #3
    matthias
    Guest

    Re: copy spreadsheet in new workbook, macro problem

    Hello,

    the macro works perfectly!!!
    but now he copies the worksheets in the same workbook.
    I want to copy the sheets in an existing workbook (for instance:
    c:\book1.xls\sheet1 for sheets 1 and so on)

    is this possible??


  4. #4
    Tom Ogilvy
    Guest

    Re: copy spreadsheet in new workbook, macro problem

    Isn't that what you asked for?
    > i want the 2 copied sheets in the same workbook!!


    If this is another question then I gues you are asking to copy to another
    existing workbook. I assume the workbook you want to copy to is Book1.xls
    located in "C:\" If it isn't open, then open it.


    Dim s as String, s1 as String
    Dim bk as Workbook, bk1 as Workbook
    s = "Book1.xls"
    s1 = "C:\" & s

    set bk1 = Activeworkbook

    On Error Resume next
    set bk = Workbooks(s)
    On errror goto 0
    if bk is nothing then
    set bk = Workbooks.Open(s1)
    end if

    If bk1.Worksheets("sheet1"). _
    Range("A1") = bk1.Worksheets( _
    "sheet2").Range("A1") Then
    bk1.Worksheets("sheet1").Copy _
    After:=bk.Worksheets(bk.Worksheets.count)
    Cells.Copy
    Cells.PasteSpecial xlPasteValues
    Cells(1).Select
    Application.CutCopyMode = False

    bk1.Worksheets("sheet2").Copy _
    After:=bk.Worksheets(bk.Worksheets.count)
    Cells.Copy
    Cells.PasteSpecial xlPasteValues
    Cells(1).Select
    Application.CutCopyMode = False

    End If

    --
    Regards,
    Tom Ogilvy

    "matthias" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > the macro works perfectly!!!
    > but now he copies the worksheets in the same workbook.
    > I want to copy the sheets in an existing workbook (for instance:
    > c:\book1.xls\sheet1 for sheets 1 and so on)
    >
    > is this possible??
    >




  5. #5
    matthias
    Guest

    Re: copy spreadsheet in new workbook, macro problem

    thanks it is perfect!!!!!


+ 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