Here is the code:
numLoansSoldPrev = Range("LoansSold:NewHedges").Cells.Count
If numLoansSoldPrev > 3 Then
Set rngLoansSoldStart = ActiveWorkbook.Sheets("Email").Range("LoansSold").Offset(1, 1)
Let strLoansSoldStart = rngLoansSoldStart.Address
Set rngLoansSoldEnd = ActiveWorkbook.Sheets("Email").Range("NewHedges").Offset(-2, 5)
Let strLoansSoldEnd = rngLoansSoldEnd.Address
Range(strLoansSoldStart & ":" & strLoansSoldEnd).Select
Selection.ClearContents
End If
The commands below the beginning of the if statement work just fine on their own, but every time I try to execute this, I get "block if without end if" despite clearly having one at the bottom.
I have numerous of these if statements in the file but they are all in the same format, so it's not like one if statement is missing an end if.
Any idea?
Expanded Code:
' DECLARE NEW LONGS VARIABLES
Dim numNewLoansPrev As Integer
Dim rngLoansStart As Range
Dim rngLoansEnd As Range
Dim strLoansStart As String
Dim strLoansEnd As String
' DECLARE NEW LOANS SOLD VARIABLES
Dim numLoansSoldPrev As Integer
Dim rngLoansSoldStart As Range
Dim rngLoansSoldEnd As Range
Dim strLoansSoldStart As String
Dim strLoansSoldEnd As String
' DECLARE NEW HEDGES VARIABLES
Dim numNewHedges As Integer
Dim rngNewHedgesStart As Range
Dim rngNewHedgesEnd As Range
Dim strNewHedgesStart As String
Dim strNewHedgesEnd As String
Dim xcess As Integer
' Active E-mail Tab
Worksheets("Email").Activate
' CLEAR EXCESS NEW LONG POSITIONS
numNewLoansPrev = Range("NewLongs:LoansSold").Cells.Count
If numNewLoansPrev > 3 Then
Set rngLoansStart = ActiveWorkbook.Sheets("Email").Range("NewLongs").Offset(1, 1)
Set strLoansStart = rngLoansStart.Address
Set rngLoansEnd = ActiveWorkbook.Sheets("Email").Range("LoansSold").Offset(-2, 5)
Set strLoansEnd = rngLoansEnd.Address
Range(strLoansStart & ":" & strLoansEnd).Select
Selection.ClearContents
End If
' CLEAR EXCESS SOLD LONG POSITIONS
numLoansSoldPrev = Range("LoansSold:NewHedges").Cells.Count
If numLoansSoldPrev > 3 Then
Set rngLoansSoldStart = ActiveWorkbook.Sheets("Email").Range("LoansSold").Offset(1, 1)
Set strLoansSoldStart = rngLoansSoldStart.Address
Set rngLoansSoldEnd = ActiveWorkbook.Sheets("Email").Range("NewHedges").Offset(-2, 5)
Set strLoansSoldEnd = rngLoansSoldEnd.Address
Range(strLoansSoldStart & ":" & strLoansSoldEnd).Select
Selection.ClearContents
End If
' CLEAR EXCESS NEW HEDGES POSITIONS
numNewHedges = Range("NewHedges:Pnl").Cells.Count
If numNewHedges > 3 Then
Set rngNewHedgesStart = ActiveWorkbook.Sheets("Email").Range("NewHedges").Offset(1, 1)
Set strNewHedgesStart = rngNewHedgesStart.Address
Set rngNewHedgesEnd = ActiveWorkbook.Sheets("Email").Range("PnL").Offset(-2, 5)
Set strNewHedgesEnd = rngNewHedgesEnd.Address
Range(strNewHedgesStart & ":" & strNewHedgesEnd).Select
Selection.ClearContents
End If