Update links in excel file
Hi,
I have an excel file which contains a financial model which I would like to use for all the stocks on the S&P 500. So, I have a masterlist of all the stocks on the S&P 500. I am trying to program excel to go through the list one-by-one, open the file with the model and insert the stock name in one of the cells and let the file update itself from Bloomberg and then close it and save it automatically. My problem is I dont know how to autoupdate and automatically close the file once the update is complete.
This is what I have so far:
==================================
Sub UpdateBloomberg()
Dim Temp, TempFile As String
Dim a, I As Integer
Range("C6").Select 'this selects the column with all the stocks
Range(Selection, Selection.End(xlDown)).Select
For a = 1 To 500
Temp = Cells(a, 3).Value
I = 1
Do While Mid(Temp, I, 1) <> " "
TempFile = TempFile + (Mid(Temp, I, 1))
I = I + 1
Loop
TempFile = "C:\Documents and Settings\Administrator\Desktop\Test\" + TempFile + ".xls"
MsgBox TempFile
Workbooks.Open Filename:="FINANCIAL MODEL.xls"
Application.Run "BLPLinkReset"
Application.Run "RefireBLP"
ActiveWorkbook.SaveAs Filename:=TempFile
ActiveWorkbook.Close
TempFile = ""
Next a
End Sub
===========================
I would appreciate any help.
Thanks
Ihsan
|