Hi all -
I have a macro that is supposed to communicate with Bloomberg to retrieve some static info from certain fields. The macro looks through my excel sheet that has columns A & B (Cusip and AbsRefID, respectively), and basically concatenates it into cell C so that Bloomberg can read it. Then I retrieve data points using Bloomberg's BDP function for each column. I'm getting an expected end of statement error in the highlighted portion of the code below. Any help is greatly appreciated.
Sub Format_1st_Run()
For Each ws In Sheets
ws.Activate
Dim A As Long, B As Long
A = Range("B" & Rows.Count).End(xlUp).Row
For B = A To 1 Step -1
'Define Security Type so BB can read
If Range("B" & B).Value Like "AGY*" Then Range("C" & B).Value = Range("A" & B).Value & " Corp"
If Range("B" & B).Value Like "CD*" Then Range("C" & B).Value = Range("A" & B).Value & " Corp"
If Range("B" & B).Value Like "CORP*" Then Range("C" & B).Value = Range("A" & B).Value & " Corp"
If Range("B" & B).Value Like "MUNI*" Then Range("C" & B).Value = Range("A" & B).Value & " Muni"
If Range("B" & B).Value Like "PREF*" Then Range("C" & B).Value = Range("A" & B).Value & " Pfd"
If Range("B" & B).Value Like "PRST*" Then Range("C" & B).Value = Range("A" & B).Value & " Pfd"
If Range("B" & B).Value Like "FOREIGN*" Then Range("C" & B).Value = Range("A" & B).Value & " Corp"
'Look up BB Data Points
If Range("C" & B).Value Like "*Corp" Then Range("D" & B).Formula = "=BDP(Range("C" & B).Value, ""CALLED_DT"")"
If Range("C" & B).Value Like "*Corp" Then Range("E" & B).Formula = "=BDP(Range("C" & B).Value, ""CALLED_PX"")"
If Range("C" & B).Value Like "*Corp" Then Range("F" & B).Formula = "=BDP(Range("C" & B).Value, ""MOST_RECENT_REPORTED_FACTOR"")"
If Range("C" & B).Value Like "*Muni" Then Range("D" & B).Formula = "=BDP(Range("C" & B).Value, ""MUNI_RECENT_REDEMP_DT"")"
If Range("C" & B).Value Like "*Muni" Then Range("E" & B).Formula = "=BDP(Range("C" & B).Value, ""MUNI_RECENT_REDEMP_PX"")"
If Range("C" & B).Value Like "*Muni" Then Range("F" & B).Formula = "=BDP(Range("C" & B).Value, ""MUNI_RECENT_REDEMP_TYP"")"
If Range("C" & B).Value Like "*Pfd" Then Range("D" & B).Formula = "=BDP(Range("C" & B).Value, ""CALLED_DT"")"
If Range("C" & B).Value Like "*Pfd" Then Range("E" & B).Formula = "=BDP(Range("C" & B).Value, ""CALLED_PX"")"
'Check to make sure that the cells are NOT requesting data
'Delete bad data from Corp
If Range("C" & B).Value Like "*Corp" And Range("F" & B).Value Like "1" Then Rows(B).Delete
If Range("C" & B).Value Like "*Corp" And Range("F" & B).Value Like "0" Then Rows(B).Delete
If Range("C" & B).Value Like "*Corp" And Range("D" & B).Value Like "N/A*" Then Rows(B).Delete
If Range("C" & B).Value Like "*Corp" And Range("E" & B).Value Like "N/A*" Then Rows(B).Delete
If Range("C" & B).Value Like "*Corp" And Range("F" & B).Value Like "N/A*" Then Rows(B).Delete
If Range("C" & B).Value Like "*Corp" And Month(Range("D" & B)) <> Month(Date) Then Rows(B).Delete
'Delete bad data from Muni
If Range("C" & B).Value Like "*Muni" And Range("F" & B).Value <> "Called in Full" Then Rows(B).Delete
If Range("C" & B).Value Like "*Muni" And Month(Range("D" & B)) <> Month(Date) Then Rows(B).Delete
'Delete bad data from Pfd
If Range("C" & B).Value Like "*Pfd" And Range("D" & B).Value Like "N/A*" Then Rows(B).Delete
If Range("C" & B).Value Like "*Pfd" And Range("E" & B).Value Like "N/A*" Then Rows(B).Delete
If Range("C" & B).Value Like "*Pfd" And Month(Range("D" & B)) <> Month(Date) Then Rows(B).Delete
'For Corp, put any security with a factor other than 0 or 1 into a new worksheet
'Verify that factor is in current month
Next B
Next ws
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
End Sub
Bookmarks