Hi,
In my macro I need to copy paste a data range from one workbook to another. The data source workbook is always the same name but the destination workbook changes periodically and has no naming convention.
The destination workbook is also not the workbook in which the VBA code runs, so I can't use 'ThisWorkbook'. The destination workbook does however have a sheet which is always called the same, but I can't find out how (if possible) activating a sheet which is within a variable-named workbook.
Here's my code:
Sub Macro17()
'
' Macro17 Macro
'
Windows("datasource.csv").Activate
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("destination.xlsx").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
In my macro I need to copy paste a data range from one workbook to another. The data source workbook is always the same name but the destination workbook changes periodically and has no naming convention.
The destination workbook is also not the workbook in which the VBA code runs, so I can't use 'ThisWorkbook'. The destination workbook does however have a sheet which is always called the same, but I can't find out how (if possible) activating a sheet which is within a variable-named workbook.
Here's my code:
Sub Macro17()
'
' Macro17 Macro
'
Windows("datasource.csv").Activate
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("destination.xlsx").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub