Hi All,
I'm attempting to write a macro to copy a range from another open workbook, then paste that data into the workbook that the macro is in. What I have so far works fine in tests, but in the real world there will be some variables I need to address.
There may be other open work books at the time the macro is run.
The entire target workbook name will be unkown, but will always contain "Changes"
The entire target worksheet name will be unkown, but will always contain "Changes"
Here is the code I am working with:
Sub CopierTest()
Dim wb As Workbook, x As String
Application.DisplayAlerts = False
For Each wb In Workbooks
If wb.Name <> ThisWorkbook.Name _
Then x = wb.Name
Next wb
Workbooks(x).Activate
Worksheets("Sheet1").Activate
Columns("A:H").Select
Selection.Copy
ThisWorkbook.Worksheets("PasteHere").Activate
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Workbooks(x).Close savechanges:=False
Application.DisplayAlerts = True
End Sub
Any help would be greatly appreciated, thanks!
Bookmarks