kualjo
04-15-2011, 12:30 PM
Not sure why this is not working. I want to open a raw data file, copy all cells, then paste into a master workbook. At the Cells.Select command, I get RTE 1004.
Here is the code:
Sub GetExpFile()
Set UpFile = ActiveWorkbook
DataFileName = Application.GetOpenFilename(, , "Get Export File")
If DataFileName = "False" Then
Exit Sub
End If
Set DataFile = Workbooks.Open(DataFileName)
Cells.Select
Selection.Copy
UpFile.Activate
Sheets("Sheet1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
DataFile.Close
End Sub
I tried adding a line to activate DataFile before selecting, but that didn't change anything. Any ideas?
Here is the code:
Sub GetExpFile()
Set UpFile = ActiveWorkbook
DataFileName = Application.GetOpenFilename(, , "Get Export File")
If DataFileName = "False" Then
Exit Sub
End If
Set DataFile = Workbooks.Open(DataFileName)
Cells.Select
Selection.Copy
UpFile.Activate
Sheets("Sheet1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
DataFile.Close
End Sub
I tried adding a line to activate DataFile before selecting, but that didn't change anything. Any ideas?