mjohnston0209
Board Regular
- Joined
- Nov 6, 2017
- Messages
- 55
I have a workbook that I update every week. Part of the name is based on the date and therefore changes each week (i.e. Monthly Revenue (07-10-22).xlsx then Monthly Revenue (07-17-22).xlsx). The date is written as text in Cell U4 of the workbook.
My goal is to declare a workbook variable and then set the name of the workbook. I am having difficulty setting the workbook name because it always changes. I know I can set a workbook name by stating ActiveWorkbook, but I want set the name by a specific name in case I am not in the activeworkbook when I first start running the macro.
I currently use this as my coding.
However, the macro does not work if the workbook is not active when I run it.
Any help would be greatly appreciated!
My goal is to declare a workbook variable and then set the name of the workbook. I am having difficulty setting the workbook name because it always changes. I know I can set a workbook name by stating ActiveWorkbook, but I want set the name by a specific name in case I am not in the activeworkbook when I first start running the macro.
I currently use this as my coding.
VBA Code:
Dim wb As Workbook
Set wb = Workbooks("Monthly Revenue (" & Cells(4, 21) & ").xlsx")
wb.Activate
However, the macro does not work if the workbook is not active when I run it.
Any help would be greatly appreciated!