PC Review


Reply
Thread Tools Rate Thread

Change workbook path in formula

 
 
=?Utf-8?B?TmFzY2ltZW50bywgRGFuaWVs?=
Guest
Posts: n/a
 
      14th Nov 2007
I have several workbooks in c:\project\ named 'pr_A', 'pr_B', 'pr_C'...
they all have in common a worksheet 'total_data' where are several tables
that agregate the data in the remaining worksheets in the same workbook.
each project as a diferent way of agregate the information but all use the
same worksheet 'total_data'.
i have another workbook named 'main_project' that have also a workshet
total_data but in this case it goes to the file c:\project\pr_a.xls for the
data.
ex: formula in A8 := 'c:\project\[pr_a.xls]total_data'!A8
formula in B9 := 'c:\project\[pr_a.xls]total_data'!B9
(...)

i have the following sub

Public Sub change_file(ByVal actual_pr As String, ByVal new_pr As String)

Application.Workbooks.Open "c:\project\" + new_pr + ".xls"
Application.Calculate
Application.ActiveWorkbook.Close True
Sheet1.Range("A1Z250").Replace What:=actual_pr, Replacement:=new_pr,
SearchOrder:=xlByColumns, MatchCase:=True
Application.CalculateFull

End Sub

i wanted that 'main_project' could change its data "on-the-fly"
if i wanted to see project B i would do

change_file getname_actual_file(), "pr_b"
setname_actual_file "pr_b" ' saves the string in a worksheet cell

however each time an value its replaced it gives an error message (no quite
this because its in portuguese)
says the link was not updated because the "pr_b.xls" wasn't recalculated
last time it was saved. ok to update or cancel.

there are hundred or replacements

what i'm doing wrong ?
it's possible to answer yes to all by default?

p.s.:
calculation its set to manual because some external ad-ins, that are too
complex and if its automatic each time i make a change it take hours...


Thank You
Daniel
 
Reply With Quote
 
 
 
 
Colby Africa
Guest
Posts: n/a
 
      14th Nov 2007
Try Application.DisplayAlerts = false

Excel will choose the default response for each alert for you.

http://msdn2.microsoft.com/en-us/library/aa175241(office.11).aspx

Hope this helps!

Colby Africa
http://colbyafrica.blogspot.com

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula Result Change when Workbook Sent by E-mail Rich F Microsoft Excel Misc 4 4th Sep 2008 07:46 PM
I have to change a bunch of formula that need to reference a different workbook. Marc Microsoft Excel Worksheet Functions 5 19th Jul 2006 02:56 AM
Path changing in formula when workbook in different folder hals_left Microsoft Excel Misc 0 8th Jul 2004 05:01 PM
How to interpret a path to another workbook and use in formula bar hals_left Microsoft Excel Misc 5 10th May 2004 10:21 AM
How to interpret a path to another workbook and use in formula bar hals_left Microsoft Excel Programming 5 10th May 2004 10:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:35 AM.