![]() |
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 |
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" wrote in message oups.com... 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 |
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?? |
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" wrote in message oups.com... 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?? |
copy spreadsheet in new workbook, macro problem
thanks it is perfect!!!!!
|
All times are GMT +1. The time now is 03:43 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com