VBA code to call the name of current file

  • Thread starter Thread starter Phatchef24
  • Start date Start date
P

Phatchef24

Hi,

I was wondering if anybody knew the VBA code to call the name of th
excel file that contained the module a macro was in?

My issue is that the name of the file changes every month so using

Windows("210 Product Expense Report - August Close.xls").Activate

wont work in september. I was just wondering if there was a way to d
this without using Inputbox and just entering the correct name eac
month.


Thanks
 
ThisWorkbook will always return a reference to the workbook
containing the code. Therefore, you can do something like

ThisWorkbook.Activate
' or
Windows(ThisWorkbook.Name).Activate

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top