Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and Paste between Spread Sheets


Hi all,

How can I setup a macro that will pull data in from a range.. From one
xls spreadsheet(testLog.xls)(summary tab) to another
(Script.xls)(findings tab)?


--
lbargers
------------------------------------------------------------------------
lbargers's Profile: http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=527216

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Copy and Paste between Spread Sheets

Hi there lbargers,

You could try something like this ...

Sub CopyMyDataFromBookToBook()

Dim wbCopy as Workbook, wbPaste as Workbook
Dim wsCopy as Worksheet, wsPaste as Worksheet
Dim rngCopy as Range, rngPaste as Range

Set wbCopy = Workbooks("testLog.xls")
Set wbPaste = Workbooks("Script.xls")
Set wsCopy = wbCopy.Sheets("summary")
Set wsPaste = wbPaste.Sheets("findings")
Set rngCopy = wsCopy.Range("A1:A10")
Set rngPaste = wsPaste.Range("A1:A10")

rngCopy.Copy Destination:=rngPaste
Application.CutCopyMode = False

End Sub

Change the ranges to suit.

HTH

--
Regards,
Zack Barresse, aka firefytr
To email, remove NOSPAM


"lbargers" wrote in
message ...

Hi all,

How can I setup a macro that will pull data in from a range.. From one
xls spreadsheet(testLog.xls)(summary tab) to another
(Script.xls)(findings tab)?


--
lbargers
------------------------------------------------------------------------
lbargers's Profile:
http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=527216



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and Paste between Spread Sheets


Hey Zach, Thanks for your fast response...

Will the method you showed copy all the data in the fields, or just
those that contain data? The file are located in different directories,
how do I set the path?

Thanks again, your help is greatly appreciated...


--
lbargers
------------------------------------------------------------------------
lbargers's Profile: http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=527216

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Copy and Paste between Spread Sheets

It will only copy the range you specify. Are you looking at a
variable/dynamic range? All of the data? Also, I assumed the workbooks
would be open. If they are not (or you don't know if they will be at
runtime) you can use something like this ...

Sub CopyMyDataFromBookToBook()

Dim wbCopy As Workbook, wbPaste As Workbook
Dim wsCopy As Worksheet, wsPaste As Worksheet
Dim rngCopy As Range, rngPaste As Range

If IsWbOpen("testLog.xls") Then
Set wbCopy = Workbooks("testLog.xls")
Else
Set wbCopy = Workbooks.Open("C:\YourPathHere\testLog.xls")
End If

If IsWbOpen("Script.xls") Then
Set wbPaste = Workbooks("Script.xls")
Else
Set wbPaste = Workbooks.Open("C:\YourPathHere\Script.xls")
End If

Set wsCopy = wbCopy.Sheets("summary")
Set wsPaste = wbPaste.Sheets("findings")
Set rngCopy = wsCopy.Range("A1:A10")
Set rngPaste = wsPaste.Range("A1:A10")

rngCopy.Copy Destination:=rngPaste
Application.CutCopyMode = False

End Sub

Function IsWbOpen(strName As String) As Boolean
On Error Resume Next
IsWbOpen = Len(Workbooks(strName).Name)
End Function

--
Regards,
Zack Barresse, aka firefytr
To email, remove NOSPAM


"lbargers" wrote in
message ...

Hey Zach, Thanks for your fast response...

Will the method you showed copy all the data in the fields, or just
those that contain data? The file are located in different directories,
how do I set the path?

Thanks again, your help is greatly appreciated...


--
lbargers
------------------------------------------------------------------------
lbargers's Profile:
http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=527216



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and Paste between Spread Sheets


I'll explain a little bit further as I am brand new to excel and was
assigned an excel automation project at work. I am an applications
developer and understand VB code. My question is how can I set up a
marco or other code routine to pull data into my spreadsheet from a
seperate spreadsheet at a different directory location.

The first spreadsheet (testScript.xls) contains a [Summary Tab].
The second spreadsheet(SummaryScript.xls) will contain a [Findings
Tab].

I want the second spreadsheet (SummaryScript.xls) to pull data from the
[Summary Tab] of the testScript.xls.

The data I want pulled will come from row 3, starting at Column E
through Column IV(E3:IV3) As the loop occurs I would like data in this
range to populate rows in The [Findings Tab] of the SummaryScript.xls
Spreadsheet.

What I want to do is copy the cell data in row 3 of any column (there
could be up to 255) where data is present, I would like that data sent
or pullled into column C of the [Findings Tab] in he SummaryScript.xls.
But it should be place row after row.

For instance if columns E3, L3, M3, AD3, AJ3... Contain a value I want
these values respectively placed into column C in the Findings Tab...

Thanks,
Larry Bargers


--
lbargers
------------------------------------------------------------------------
lbargers's Profile: http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=527216



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Copy and Paste between Spread Sheets

So if E3 has data, then no data from F3:J3, do not copy those, etc? And you
want this data pasted into column C, starting at row 3? Do you want the
blanks (i.e. F3:J3) pasted as well, or only those with data? Will this be
done multiple times? Do we need to find the last row in column C? I'm
assuming you'll be calling this from the SummaryScript workbook?

--
Regards,
Zack Barresse, aka firefytr
To email, remove NOSPAM

"lbargers" wrote in
message ...

I'll explain a little bit further as I am brand new to excel and was
assigned an excel automation project at work. I am an applications
developer and understand VB code. My question is how can I set up a
marco or other code routine to pull data into my spreadsheet from a
seperate spreadsheet at a different directory location.

The first spreadsheet (testScript.xls) contains a [Summary Tab].
The second spreadsheet(SummaryScript.xls) will contain a [Findings
Tab].

I want the second spreadsheet (SummaryScript.xls) to pull data from the
[Summary Tab] of the testScript.xls.

The data I want pulled will come from row 3, starting at Column E
through Column IV(E3:IV3) As the loop occurs I would like data in this
range to populate rows in The [Findings Tab] of the SummaryScript.xls
Spreadsheet.

What I want to do is copy the cell data in row 3 of any column (there
could be up to 255) where data is present, I would like that data sent
or pullled into column C of the [Findings Tab] in he SummaryScript.xls.
But it should be place row after row.

For instance if columns E3, L3, M3, AD3, AJ3... Contain a value I want
these values respectively placed into column C in the Findings Tab...

Thanks,
Larry Bargers


--
lbargers
------------------------------------------------------------------------
lbargers's Profile:
http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=527216



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
Copy and Paste with Macro Between sheets jlclyde Excel Discussion (Misc queries) 1 November 8th 07 05:07 PM
Copy&paste of several sheets Lorenz Excel Discussion (Misc queries) 1 May 29th 07 10:08 PM
Copy and paste between sheets dmg[_2_] Excel Programming 5 November 1st 05 12:56 PM
Copy and paste spread sheet broogle Excel Programming 2 March 21st 05 02:22 AM
MS Excel Sheets...how to copy and paste ? tina SPEILBERG Excel Programming 1 August 4th 03 07:15 AM


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