Macro Copy from Workbook to a different Workbook

Martin Jones

New Member
Joined
Dec 3, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Martin
Hello,
I would much appreciate it if someone could help with this macro. I am trying to copy a range that contains formulas from one Workbook to another Workbook. This can be easily done with Worksheets that are in the same Workbook. The challenge is the second workbook name changes every month. I would like for the macro to dynamically pick the 2nd name up based on the workbook I have opened.
Here is my current macro and it works on the named files but again the second workbook has a different name every month. I can manually edit the macro with the new name but I would prefer that the macro do that automatically.
Sub Copy_m()
'
' Copy Macro
'
' Keyboard Shortcut: Ctrl+d
'
Windows("Macros for Ad Hoc Expenditure Report-1.xlsm").Activate
Range("T1:X29").Select
Selection.Copy
Windows("NOV Ad Hoc Expenditure Report - fin-test.xlsx").Activate
Range("T1").Select
ActiveSheet.Paste
End Sub

Any help would be much appreciated.
Martin
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
you could do something like this which asks the user which workbook to copy to
VBA Code:
Sub test()
Dim wb As Workbook
For Each wb In Workbooks
    wb.Activate
   answer = MsgBox("do you want copy to this workbook", vbYesNo + vbQuestion)
   If answer = vbYes Then
    Exit For
   End If
Next wb

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,705
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top