LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Doing a copy-paste offest between 2 workbooks

Here is what I am doing: Counting each of the files in the directory,
then I am taking the heading in cell A2 a pasting it into my workbook
(that is serving as a data collection worksheet). Each time I offset
the heading by 7 since the range of data I am copying in is 7 rows. I
can't seem to figure out how to get the range to copy over and offset
itself. Any help is appreciated!

Sub TravelCompile()
Dim WB$(30)
Set sPg = ThisWorkbook.Sheets("Summary")
FileLocation = "O:\FINANCE\Finance190\Common\Planning&Analysi s
\Monthly Summary\May 2007\Travel"
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set the folder that contains all the files
Set Folder = objFSO.getfolder(FileLocation)
'Create a file collection
Set Location = Folder.Files
i = 0
For Each File In Location
If Right(File, 3) = "xls" Then
i = i + 1
WB$(i) = Mid(File, Len(FileLocation & "\") + 1, Len(File))
End If
Next
For x = 1 To i
Set cur = Workbooks.Open(Filename:=FileLocation & "\" & WB$
(x))
Set fPg = cur.Sheets(1)
With sPg
With .Range("A7")
.Offset((x - 1) * 7, 0) = fPg.Range("A2")
End With
With fPg.Range("G96:AE103")
.Select
End With
Selection.Copy
.Windows("TravelFees Template Macro.xls").Activate
.Range("b7").Select
.ActiveSheet.Paste
End With
'fPg.PrintOut
cur.Close
Next x
End Sub

 
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
Can NOT copy / paste across workbooks CL Chuck Excel Discussion (Misc queries) 3 September 29th 07 06:01 PM
Copy and paste from several Workbooks bpotter Excel Programming 2 August 25th 06 05:24 PM
Copy and Paste Between Workbooks Lee Excel Programming 2 November 13th 03 08:08 PM


All times are GMT +1. The time now is 01:26 AM.

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"