Results 1 to 24 of 24

Expected: end of statement in Macro

Threaded View

  1. #1
    Registered User
    Join Date
    10-16-2012
    Location
    tn
    MS-Off Ver
    Excel 2003
    Posts
    24

    Expected: end of statement in Macro

    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
    Last edited by jeffreybrown; 10-16-2012 at 06:21 PM. Reason: Please use code tags...Thanks.

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