ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying a range from one workbook to another workbook (https://www.excelbanter.com/excel-programming/357145-re-copying-range-one-workbook-another-workbook.html)

caldog

Copying a range from one workbook to another workbook
 
Oops forgot to show the error message that I'm getting.

'Run time Error "438"

Object doesn't support this property or method

See line that says 'Error happens at next line'

Steve

"caldog" wrote:

I know there is probably a simple answer to this problem, but fot the life of
me, I can't find it.

Here is my code:

Private Sub SingleValues_Click()
Workbooks.Open Filename:="C:\Excel\Data1.xls"

'Refresh Data
'Sheets("Singles").Select
'Selection.QueryTable.Refresh BackgroundQuery:=False
'Sheets("Doubles").Select
'Selection.QueryTable.Refresh BackgroundQuery:=False

'Copy Data
Windows("Data1.xls").Activate
Sheets("Singles").Select
Range("A9:F51").Copy
Windows("Data2.xls").Activate
Sheets("Single Game Stats").Select

'Error happens at next line
Range("A9:F51").Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

'Sort Download
Windows("Jai-Alai.xls").Activate
Worksheets("Single Game Stats").Range("A9:F51").Select
Selection.Sort Key1:=Range("B9"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Windows("Data1.xls").Activate
ActiveWorkbook.Close
End Sub

Thanks for the help

Steve



All times are GMT +1. The time now is 02:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com