Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Copy and paste from several Workbooks

I am trying to write a macro to copy the contents of a cell in one
workbook to a cell in another workbook. It will be the same cell every
time I run the macro. I have used the recorder to create a macro but I
was wondering if I could clean it up a little. Does anyone have a
suggestion. Here is part of the code.



Windows("Rt 109 Downtime Report.xls").Activate
Sheets("Today's ").Select
Application.Run "'Rt 109 Downtime Report.xls'!problem"
Sheets("Problem Well Sort").Activate
Range("M70").Select
Selection.Copy
Windows("NRF_Randy C-Aug-06.xls").Activate
Range("D3").Select
Selection.PasteSpecial Paste:=xlValues
Windows("Rt 109 Downtime Report.xls").Activate
Range("M69").Select
Application.CutCopyMode = False
Selection.Copy
Windows("NRF_Randy C-Aug-06.xls").Activate
Range("E3").Select
Selection.PasteSpecial Paste:=xlValues
Windows("Rt 109 Downtime Report.xls").Activate
Range("B69").Select
Application.CutCopyMode = False
Selection.Copy
Windows("NRF_Randy C-Aug-06.xls").Activate
Range("G3").Select
Selection.PasteSpecial Paste:=xlValues
Windows("Rt 109 Downtime Report.xls").Activate
Range("B70").Select
Application.CutCopyMode = False
Selection.Copy
Windows("NRF_Randy C-Aug-06.xls").Activate
Range("H3").Select
Selection.PasteSpecial Paste:=xlValues

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Copy and paste from several Workbooks

Dim sh as Worksheet
Dim sh1 as Worksheet
Windows("Rt 109 Downtime Report.xls").Activate
Sheets("Today's ").Select
Application.Run "'Rt 109 Downtime Report.xls'!problem"
set sh = Workbooks("Rt 109 Downtime Report.xls") _
.Worksheets("Problem Well Sort").
Set sh1 = Workbooks("NRF_Randy C-Aug-06.xls").worksheets(1)
sh1.Range("D3").Value = sh.Range("M70").value
sh1.Range("E3").Value = sh.Range("M69").Value
sh1.Range("G3").Value = sh.Range("B69").Value
sh1.Range("H3").Value = sh.Range("B70").Value


change the 1 in worksheets(1) to reflect the name of the sheet you want to
copy to (unless it will be the first sheet in the tab order - then you can
leave it)

--
Regards,
Tom Ogilvy



"bpotter" wrote:

I am trying to write a macro to copy the contents of a cell in one
workbook to a cell in another workbook. It will be the same cell every
time I run the macro. I have used the recorder to create a macro but I
was wondering if I could clean it up a little. Does anyone have a
suggestion. Here is part of the code.



Windows("Rt 109 Downtime Report.xls").Activate
Sheets("Today's ").Select
Application.Run "'Rt 109 Downtime Report.xls'!problem"
Sheets("Problem Well Sort").Activate
Range("M70").Select
Selection.Copy
Windows("NRF_Randy C-Aug-06.xls").Activate
Range("D3").Select
Selection.PasteSpecial Paste:=xlValues
Windows("Rt 109 Downtime Report.xls").Activate
Range("M69").Select
Application.CutCopyMode = False
Selection.Copy
Windows("NRF_Randy C-Aug-06.xls").Activate
Range("E3").Select
Selection.PasteSpecial Paste:=xlValues
Windows("Rt 109 Downtime Report.xls").Activate
Range("B69").Select
Application.CutCopyMode = False
Selection.Copy
Windows("NRF_Randy C-Aug-06.xls").Activate
Range("G3").Select
Selection.PasteSpecial Paste:=xlValues
Windows("Rt 109 Downtime Report.xls").Activate
Range("B70").Select
Application.CutCopyMode = False
Selection.Copy
Windows("NRF_Randy C-Aug-06.xls").Activate
Range("H3").Select
Selection.PasteSpecial Paste:=xlValues


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Copy and paste from several Workbooks


Thanks That works great!!!

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
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Copy and paste between workbooks keith Excel Discussion (Misc queries) 2 February 18th 09 04:46 PM
Copy/Paste into new workbooks [email protected] Excel Programming 4 August 16th 06 10:29 PM
Copy and paste between workbooks? Frigid_Digit[_2_] Excel Programming 6 September 24th 05 03:39 PM
Copy and paste - two workbooks M Shannon Excel Programming 1 September 12th 04 07:37 PM


All times are GMT +1. The time now is 09:25 AM.

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

About Us

"It's about Microsoft Excel"