View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ikaabod[_60_] Ikaabod[_60_] is offline
external usenet poster
 
Posts: 1
Default Copy data from one file to another


Does this solve your problem?

PatchFname = Application.GetOpenFilename("Excel files (*.xls), *.xls")
If PatchFname < "" Then
Workbooks.Open PatchFname
PatchFname = ActiveWorkbook.Name
End If
TimT Wrote:
hello all,
I'm trying to prompt a user to open a workbook (and dim that filename)
so
data from multiple tabs can be copied to corresponding tabs in the
current
open workbook. The code would need to go back and forth between the
workbooks
to copy and paste multiple areas.
I get a subscript out of range when I run this code from a module.
Here is some of the code I have so far:

Public Function RunPatch()
Dim PatchFname As String

PatchFname = Application.GetOpenFilename("Excel files (*.xls), *.xls")
If PatchFname < "" Then
Workbooks.Open PatchFname
End If

'Wages
Sheets("Wages").Select
Range("A11:BG17").Select
Selection.Copy
Windows("1040 Workpapers V2.1.xls").Activate
Sheets("Wages").Select
Range("A11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

'Dividends
Windows(PatchFname).Activate

Sheets("Interest & Dividends").Select
Range("A17:C36").Select
Selection.Copy
Windows("1040 Workpapers V2.1.xls").Activate
Range("A17").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Please!! Thanks!



--
Ikaabod
------------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371
View this thread: http://www.excelforum.com/showthread...hreadid=542129