Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default inserting the name of the current workbook into a cell

If I wanted to use VBA to insert the name of the current workbook into
sheets(1).range("a1"), is there a way to do this?

Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default inserting the name of the current workbook into a cell

You could do in VBA or a worksheet formula:
http://www.contextures.com/xlfaqFun.html#SheetName

One way in VBA:

sheets(1).range("a1").value = activeworkbook.fullname
'or activeworkbook.name





Paul James wrote:

If I wanted to use VBA to insert the name of the current workbook into
sheets(1).range("a1"), is there a way to do this?

Thanks in advance.


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default inserting the name of the current workbook into a cell

Yes.

;^

"Paul James" wrote in message
...
If I wanted to use VBA to insert the name of the current workbook into
sheets(1).range("a1"), is there a way to do this?

Thanks in advance.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default inserting the name of the current workbook into a cell

Sheets(1).Range("A1").Value = ThisWorkbook.Name

or

Sheets(1).Range("A1").Value = ThisWorkbook.FullName

"Paul James" wrote in message
...
If I wanted to use VBA to insert the name of the current workbook into
sheets(1).range("a1"), is there a way to do this?

Thanks in advance.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default inserting the name of the current workbook into a cell

On Wed, 23 Jul 2003 17:07:38 -0700, "Paul James"
wrote:

If I wanted to use VBA to insert the name of the current workbook into
sheets(1).range("a1"), is there a way to do this?

Thanks in advance.


You could do something like this:

Private Sub Workbook_Open()
Worksheets(1).Range("A1").Value = ThisWorkbook.Name
End Sub

This is an event macro and will do the insertion when you open the workbook.
To enter it, <alt<F11 opens the VB Editor. Double click on ThisWorkbook on
the pertinent VBA project, and paste the code into the window that opens.

Note that the file has to be saved in order for the Workbook to have an
accessible name. This will be true whether you use this VBA method (which you
requested) or use a formula string manipulation of the CELL worksheet function.


--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Thanks to Dave and Bob

Works great. Thanks, guys.

Thanks also for that link to the Excel faq, Dave.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default inserting the name of the current workbook into a cell

Ron - Thank you for the additional information about the Workbook_Open
event. That's something I can use for a number of purposes.

And thanks also for the step by step explanation. I handn't appreciated the
benefit of double clicking on ThisWorkbook - that's also something I will
use.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
inserting current windows user id into a cell MartyMack74 Excel Worksheet Functions 2 November 14th 09 12:14 AM
Inserting Current Date in Excel 2000 mayacoleman Excel Discussion (Misc queries) 4 June 9th 09 12:27 AM
Inserting current date pdaws Excel Worksheet Functions 8 September 25th 08 12:37 AM
Inserting current date when number entered in cell & Circular reference error? Pheasant Plucker® Excel Discussion (Misc queries) 4 April 10th 07 10:39 AM
Automatically inserting current date in a cell ng66 Excel Discussion (Misc queries) 2 January 31st 07 08:44 PM


All times are GMT +1. The time now is 07:02 PM.

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

About Us

"It's about Microsoft Excel"