+ Reply to Thread
Results 1 to 2 of 2

Macro to Refresh Bloomberg Data, Wait Until Data Is Refreshed

Hybrid View

  1. #1
    Registered User
    Join Date
    06-13-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Macro to Refresh Bloomberg Data, Wait Until Data Is Refreshed

    Hey guys,

    I've scoured the internet looking for a solution here, and there are actually a lot of posts on this problem but I haven't found a solution for mine. I'm not vastly experienced with VBA, but I understand a decent amount. Appreciate any help in advance!

    Basically what I have is a spreadsheet set up to pull Bloomberg data (a finance portal, they have an excel add-in that brings in market data) for a given stock ticker, populate a few charts for it, and then print out a nicely formatted sheet. I'm doing this for about 200 tickers, so I've been trying to set up a macro that will copy/paste new tickers from a list that I have put together... then my hope is that I could have the sheet refresh and print them all out, so I'd have a nice stack of 200 printouts (one on each company) waiting for me.

    The problem is, when I try to do this code, it is taking the ticker from my sheet called "Macro" and pasting it into the right place in the sheet "Data." However, it is printing out the sheet when everything is still "N/A" trying to refresh the data... so what I get is a stack of 200 printouts with blank charts (ha).

    Here's My Code:

    Sub PrintEm()
    
    Part1A
    Part2
    
        Let X = 0
        Do While X < 2
        Part1B
        Part2
        X = X + 1
        Loop
        
    End Sub
    
    
    Sub Part1A()
        Sheets("MACRO").Select
        Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("DATA").Select
        Range("A1").Select
        ActiveSheet.Paste
        Part2
    End Sub
    
    Sub Part1B()
        Sheets("MACRO").Select
        Selection.Offset(1, 0).Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("DATA").Select
        Range("A1").Select
        ActiveSheet.Paste
        
        Sheets("DATA").Select
        Application.Run "RefreshAllWorkbooks"
        Application.Run "RefreshAllStaticData"
        ActiveWorkbook.RefreshAll
        
        Part2
    End Sub
    
    Sub Refresh()
        Application.Run "RefreshAllWorkbooks"
        Application.Run "RefreshAllStaticData"
        ActiveWorkbook.RefreshAll
        Part2
    End Sub
    
    Sub Part2()
        Application.Run "RefreshAllWorkbooks"
        Application.Run "RefreshAllStaticData"
        ActiveWorkbook.RefreshAll
        
        If ActiveSheet.Range("F8").Text Like "#N/A Updating Security" Then
       Application.OnTime Now + TimeSerial(0, 0, 4), "Refresh"
        Else
        Part3
        End If
    End Sub
    
    Public Sub Part3()
        
        Application.CutCopyMode = False
        Sheets("DATA").Select
        Application.Calculation = xlCalc
        PrintIt
    End Sub
    
    Public Sub PrintIt()
        ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
    End Sub

  2. #2
    Registered User
    Join Date
    06-13-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Macro to Refresh Bloomberg Data, Wait Until Data Is Refreshed

    Cleaned the code up a little so it is easier for you all to read, but same problem exists

    Public Sub PrintEmAll()
    
    Part1A
    Refresh
    Refresh
    Print
    
        Let X = 0
        Do While X < 2
    Part1B
    Refresh
    Refresh
    Print
        X = X + 1
        Loop
        
    End Sub
    
    
    Public Sub Part1A()
        Sheets("MACRO").Select
        Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("DATA").Select
        Range("A1").Select
        ActiveSheet.Paste
    End Sub
    
    Public Sub Part1B()
        Sheets("MACRO").Select
        Selection.Offset(1, 0).Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("DATA").Select
        Range("A1").Select
        ActiveSheet.Paste
        
    End Sub
    
    Public Sub Refresh()
        Application.Run "RefreshAllWorkbooks"
        Application.Run "RefreshAllStaticData"
        ActiveWorkbook.RefreshAll
    End Sub
    
    Public Sub PrintSheet()
        Application.CutCopyMode = False
        Sheets("DATA").Select
        
        Application.Run "RefreshAllWorkbooks"
        Application.Run "RefreshAllStaticData"
        ActiveWorkbook.RefreshAll
        
        If ActiveSheet.Range("F8").Text Like "#N/A Requesting Data..." Then
        Application.OnTime Now + TimeSerial(0, 0, 4), "Refresh"
        Else
        ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
        End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1