View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default update excel files using a vba script

In the files you want to share the data, you could open them and put in a
formula

in one cell
='C:\Myfolder\[exemple1.xls]Sheet1'!A2

and in another cell another formula

='C:\Myfolder\[exemple1.xls]Sheet1'!A3

Do this in each of the workbooks.

If you don't want a formula, then you would have to both the source workbook
and the destination workbook open at the same time (which you can do in code)

so in the source workbook you would have code like

Sub UpdateValues()

Dim rng1 as Range, bk as Workbook
Dim i as Long
set rng1 = Thisworkbook.Worksheets(1).Range("A2")
for i = 2 to 5
set bk = workbooks.open("C:\myfolder\exemple" & i & ".xls")
bk.worksheets(1).Range("A2") = rng1.Value
bk.Worksheets(1).Range("A3") = rng1.offset(1,0).Value
bk.Close SaveChanges:=True
Next

End Sub

--
Regards,
Tom Ogilvy

"adinic" wrote:


Hello. Is there a way i could update one or several files at once, using
data from another excel file? For exemple in file exemple1.xls i have in
cells a2 and a3 certain values that i want in files exemple2.xls and
exemple3.xls. I would need this for 2 or more files Thank you!


--
adinic
------------------------------------------------------------------------
adinic's Profile: http://www.excelforum.com/member.php...o&userid=31529
View this thread: http://www.excelforum.com/showthread...hreadid=533385