Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Referencing a workbook in the same directory

I'm hoping this is an easy question. Each month I run 5 reports that are
saved as excel workbooks. I have a macro template that combines and analyzes
the data from the 5 reports. Each time I do this I copy and paste the macro
template into a new folder and save the current 5 reports in this new folder.
Each of the 5 reports is saved with the exact same name.

What I want to do is change the formulas in my macro so they reference the
five reports I run without having to copy and paste them into the macro
template workbook. Is it possible to reference worksheets saved in the
current directory by not using the full path name (because the folder this is
stored in changes every month). I know its possible in html so I'm hoping
its as easy in VBA.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Referencing a workbook in the same directory

I am not too sure that I completely follow you but you can use

ThisWorkbook.Path

to get the path of the workbook executing the code...
--
HTH...

Jim Thomlinson


"Still Learning" wrote:

I'm hoping this is an easy question. Each month I run 5 reports that are
saved as excel workbooks. I have a macro template that combines and analyzes
the data from the 5 reports. Each time I do this I copy and paste the macro
template into a new folder and save the current 5 reports in this new folder.
Each of the 5 reports is saved with the exact same name.

What I want to do is change the formulas in my macro so they reference the
five reports I run without having to copy and paste them into the macro
template workbook. Is it possible to reference worksheets saved in the
current directory by not using the full path name (because the folder this is
stored in changes every month). I know its possible in html so I'm hoping
its as easy in VBA.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Referencing a workbook in the same directory

Since you just want the report data, use workbooks.add and place the report
in a new workbook.

Dim Wb1 As Workbook
Set Wb1 = ThisWorkbook
Workbooks.Add
Dim Wb2 As workbook
Set Wb2 = ActiveWorkbook
Wb1.Sheets("Your Sheet").Range("YourRange").Copy
Destination:=Wb2.Sheets1.Range("Your range")

or use this if your YourRange contains formulas.

Wb1.Sheets("Your Sheet").Range("YourRange")Copy
Wb2.Sheet1.Range("YourRange").PasteSpecial xlvalues
Wb2.Sheet1.Range("YourRange").PasteSpecial xlformats

Then you would close with,

Wb1.Close False

Leaving the report open to save or you can set up automatic saving by name
if you set up the criteria to do so.

Regards,

Alan

"Still Learning" wrote in message
...
I'm hoping this is an easy question. Each month I run 5 reports that are
saved as excel workbooks. I have a macro template that combines and
analyzes
the data from the 5 reports. Each time I do this I copy and paste the
macro
template into a new folder and save the current 5 reports in this new
folder.
Each of the 5 reports is saved with the exact same name.

What I want to do is change the formulas in my macro so they reference the
five reports I run without having to copy and paste them into the macro
template workbook. Is it possible to reference worksheets saved in the
current directory by not using the full path name (because the folder this
is
stored in changes every month). I know its possible in html so I'm hoping
its as easy in VBA.




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
Links - Copy a Workbook to another Directory Steve D Excel Discussion (Misc queries) 0 September 1st 09 09:29 PM
copying worksheets to a new workbook without formulae referencing original workbook [email protected] Excel Programming 2 October 16th 06 07:31 PM
creating directory for workbook Renee Excel Discussion (Misc queries) 3 August 28th 06 10:00 AM
Get the path to the directory that the active workbook is in Raman325[_12_] Excel Programming 1 July 1st 05 06:13 PM
opening a workbook in the current directory Richard[_16_] Excel Programming 2 August 30th 03 02:46 AM


All times are GMT +1. The time now is 10:32 AM.

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"