A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

macro to grab current workbook filename



 
 
Thread Tools Display Modes
  #1  
Old June 11th, 2009, 09:18 PM posted to microsoft.public.excel.worksheet.functions
TR Young
external usenet poster
 
Posts: 25
Default macro to grab current workbook filename

Excel 2003:
I need a macro that grabs the current workbook filename and drops it into
cell A2. I know this is simple, but my head is fried this evening....


  #2  
Old June 11th, 2009, 09:59 PM posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick
external usenet poster
 
Posts: 2,496
Default macro to grab current workbook filename

TR,

We need a better description of "cell A2"- what sheet?, what workbook?, etc,
but something like this might get you started:

Sub TRYoung()
ThisWorkbook.Sheets("Sheetname").Range("A2").Value = Activeworkbook.FullName
End Sub


HTH,
Bernie
MS Excel MVP


"TR Young" wrote in message
...
Excel 2003:
I need a macro that grabs the current workbook filename and drops it into
cell A2. I know this is simple, but my head is fried this evening....


  #3  
Old June 11th, 2009, 10:55 PM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default macro to grab current workbook filename

Do you want a macro?

You don't "need" one.

Simple worksheet function can return filename to a cell.

See Bob Phillips' site for various permutations.

http://www.xldynamic.com/source/xld.xlFAQ0002.html


Gord Dibben MS Excel MVP

On Thu, 11 Jun 2009 16:18:32 -0400, "TR Young"
wrote:

Excel 2003:
I need a macro that grabs the current workbook filename and drops it into
cell A2. I know this is simple, but my head is fried this evening....


  #4  
Old June 12th, 2009, 12:41 PM posted to microsoft.public.excel.worksheet.functions
eduardo
external usenet poster
 
Posts: 2,131
Default macro to grab current workbook filename

Hi,
In cell A2 enter

=MID(CELL("filename",A1),FIND("[",CELL("filename",A1),1)+1,FIND("]",CELL("filename",A1),1)-FIND("[",CELL("filename",A1),1)-1)

If this helps please click yes, thanks

"TR Young" wrote:

Excel 2003:
I need a macro that grabs the current workbook filename and drops it into
cell A2. I know this is simple, but my head is fried this evening....



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.