0

I realize this is probably a simple task but I am having issues activating files in my code. I need to have the user choose a file from a pop-up box, have the file opened, and then be able to rename the file so I can activate it periodically in my macro without worrying about the file name being different each time the macro is run.

I am relatively new to VBA and am taking a course online to get better. I would appreciate any help with this.

Thanks.

BigBen
  • 46,229
  • 7
  • 24
  • 40
  • 2
    When you are opening the workbook, capture the result in a workbook variable: `Set wb = Workbooks.Open...`. Now you don't need to refer to it by name at all. – BigBen Dec 17 '19 at 18:05

1 Answers1

0

Normally you don't need or want to Activate or Select - see this question for a thorough explanation why not and how to avoid doing so.

In your case, when you are opening the workbook, capture the result in a workbook variable:

Dim wb as Workbook
Set wb = Workbooks.Open(...)

Now you don't need to refer to the file by name at all.

BigBen
  • 46,229
  • 7
  • 24
  • 40