Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default define destination sheet

Help!!

My code below successfully opens a book from the right place, but now Im
trying to copy the sheet Results_first into the book which houses the
below macro, say book X.
How do I tell VB to paste the entire sheet into the book X..?

Regards

D


Dim i As Long, sName As String, sh As Worksheet
Dim dest As Range, bk As Workbook, bk1 As Workbook
Dim sh1 As Worksheet
Set bk1 = ThisWorkbook
i = 1

sName = Dir("\\server\_to_combine_files\*.xls")


Do While sName < ""

Set bk = Workbooks.Open("\\server\_to_combine_files\" & sName)


Set sh = bk.Worksheets("Results_first")


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default define destination sheet

sh.Copy Befo=Workbooks("X.xls").Sheets(1)

Change the Workbook and Sheet name to suit your needs.



--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Darin Kramer" wrote:

Help!!

My code below successfully opens a book from the right place, but now Im
trying to copy the sheet Results_first into the book which houses the
below macro, say book X.
How do I tell VB to paste the entire sheet into the book X..?

Regards

D


Dim i As Long, sName As String, sh As Worksheet
Dim dest As Range, bk As Workbook, bk1 As Workbook
Dim sh1 As Worksheet
Set bk1 = ThisWorkbook
i = 1

sName = Dir("\\server\_to_combine_files\*.xls")


Do While sName < ""

Set bk = Workbooks.Open("\\server\_to_combine_files\" & sName)


Set sh = bk.Worksheets("Results_first")


*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default define destination sheet

Try:

sh.Copy Befo=ThisWorkbook.Sheets(1)


--
Hope that helps.

Vergel Adriano


"Darin Kramer" wrote:

Help!!

My code below successfully opens a book from the right place, but now Im
trying to copy the sheet Results_first into the book which houses the
below macro, say book X.
How do I tell VB to paste the entire sheet into the book X..?

Regards

D


Dim i As Long, sName As String, sh As Worksheet
Dim dest As Range, bk As Workbook, bk1 As Workbook
Dim sh1 As Worksheet
Set bk1 = ThisWorkbook
i = 1

sName = Dir("\\server\_to_combine_files\*.xls")


Do While sName < ""

Set bk = Workbooks.Open("\\server\_to_combine_files\" & sName)


Set sh = bk.Worksheets("Results_first")


*** Sent via Developersdex http://www.developersdex.com ***

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default define destination sheet

or, if you want the copied sheet to be the last sheet in the workbook, like
this:

sh.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)

--
Hope that helps.

Vergel Adriano


"Vergel Adriano" wrote:

Try:

sh.Copy Befo=ThisWorkbook.Sheets(1)


--
Hope that helps.

Vergel Adriano


"Darin Kramer" wrote:

Help!!

My code below successfully opens a book from the right place, but now Im
trying to copy the sheet Results_first into the book which houses the
below macro, say book X.
How do I tell VB to paste the entire sheet into the book X..?

Regards

D


Dim i As Long, sName As String, sh As Worksheet
Dim dest As Range, bk As Workbook, bk1 As Workbook
Dim sh1 As Worksheet
Set bk1 = ThisWorkbook
i = 1

sName = Dir("\\server\_to_combine_files\*.xls")


Do While sName < ""

Set bk = Workbooks.Open("\\server\_to_combine_files\" & sName)


Set sh = bk.Worksheets("Results_first")


*** Sent via Developersdex http://www.developersdex.com ***

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default define destination sheet

Okay, that works... and how would I select all cells in the sheet,
instead of the whole work book..?
ie I now need to go back to source, select all cells, and then goto
destination and paste all cells....

Kind Regards
D



*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default define destination sheet

to copy all cells from one worksheet and paste in another, try something like
this:

sh.Cells.Copy Destination:=ThisWorkbook.Sheets("Sheet1").Cells(1 , 1)


--
Hope that helps.

Vergel Adriano


"Darin Kramer" wrote:

Okay, that works... and how would I select all cells in the sheet,
instead of the whole work book..?
ie I now need to go back to source, select all cells, and then goto
destination and paste all cells....

Kind Regards
D



*** Sent via Developersdex http://www.developersdex.com ***

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
TextToColumn when destination to other sheet CG Rosen Excel Discussion (Misc queries) 4 November 17th 09 09:10 PM
copied formulas refer to destination sheet not source sheet Dantron Excel Worksheet Functions 2 October 21st 09 09:51 PM
Copy every 3rd cell, define destination range for paste Meltad Excel Programming 1 September 27th 06 01:46 PM
copying and pasting from source sheet to destination sheet without naming source sht? Simon Lloyd[_753_] Excel Programming 5 June 2nd 06 06:11 PM
Hyperlinks - identifying source in destination sheet UniDave Excel Discussion (Misc queries) 0 November 25th 04 10:07 PM


All times are GMT +1. The time now is 04:17 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"