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
Bookmarks