Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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??



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default copy spreadsheet in new workbook, macro problem

thanks it is perfect!!!!!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy a spreadsheet in shared workbook Kathie Excel Worksheet Functions 3 November 12th 09 02:05 AM
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Macro to copy and append spreadsheet changes to new spreadsheet Journey Excel Discussion (Misc queries) 1 June 13th 08 04:33 PM
please help, need to copy row to separate spreadsheet in workbook nso Excel Worksheet Functions 1 May 16th 08 04:57 PM
Copy sheet from one workbook to another workbook problem Ron de Bruin Excel Programming 3 August 5th 04 07:19 PM


All times are GMT +1. The time now is 09:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"