ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code to call the name of current file (https://www.excelbanter.com/excel-programming/308926-vba-code-call-name-current-file.html)

Phatchef24[_4_]

VBA code to call the name of current file
 
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

--
Message posted from http://www.ExcelForum.com


Chip Pearson

VBA code to call the name of current file
 
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





"Phatchef24 " wrote
in message ...
Hi,

I was wondering if anybody knew the VBA code to call the name
of the
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 do
this without using Inputbox and just entering the correct name
each
month.


Thanks!


---
Message posted from http://www.ExcelForum.com/




Phatchef24[_5_]

VBA code to call the name of current file
 
That did it. Thanks

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 06:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com