Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2004, 10:38 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old December 9th, 2006, 08:06 PM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ihsan

I find myself with the same question you posed 30 months ago. Did you ever uncover a solution?

I too am trying to run an analysis on each of the S&P 500. Mine uses daily compounding the determing the compounded annualized total investment rate over a specifided period of time. The SPX_Companies tab uses a BLPB() function to get the ticker symbols on the S&P 500. the CAGR tab uses a BLPH() function to pull the stock prices and a BLPB() function to pull in the dividend data. From this the total return is calculated.

I have a macro, pasted in below, that goes between the two sheets so that the total return of each company is iteratively calculated. Unfortunately, it takes so long for the data to load that I needed to add a MSG box to pause macro termination long enough for the macro to load. This means that I have to click "okay" 500 time to complete the analysis. The Wait and senseless looping don't help because they dont idle the computer's execution. Any help would be appreciated. Here is what I have.

' CheckCAGR Macro
' Macro recorded 10/31/2006
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
For i = 500 To 1 Step -1
    Selection.Copy
    Sheets("CAGR").Select
    Application.Run "BLPLinkReset"
    Range("A5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("SPX_Companies").Select
    Msg = i
    Application.Run "BLPLinkReset"
    Application.Run "RefireBLP"

    'exittime = Now() + 2.31481481481481E-04
    'currenttime = Now()
    'Do Until currenttime > exittime
    ' currenttime = Now()
    ' Loop
    MsgBox Msg
    ActiveCell.Offset(0, 2).Range("A1:D1").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(1, -2).Range("A1").Select
Next i
End Sub

Thanks

 
Old December 11th, 2006, 05:09 AM
Authorized User
 
Join Date: Mar 2006
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you do not need the links to update dynamically, you can use DDE to update the values and this will loop through.. if you have access to Bloomberg type WAPI <go> this will show you how to programatcaly download data using DDE or an activeX component.. much quicker than using the BLP formula.. hope this helps.. let me know if you need any more info






Similar Threads
Thread Thread Starter Forum Replies Last Post
How are the Update/Cancel links wired? BKahuna BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 October 7th, 2007 12:58 PM
MS Excel - File Links - VBA a_barnsley Excel VBA 1 July 23rd, 2007 10:48 AM
Automatic links in Excel 2000 Piblon Excel VBA 2 November 22nd, 2004 02:10 AM
Update Excel File Using ADO .Net briancronin123 ADO.NET 0 June 3rd, 2004 02:20 AM
Links to MS Excel Worksheets Dudester Classic ASP Basics 0 June 7th, 2003 02:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.