I have an If statement testing to see if Range CCAddedGPSum Is Nothing, which is the case, but when it tests, it determines it to be otherwise.
When I use a Debug.Print CCAddedGPSum.Value
, I receive an error claiming that an Object is required, which indicates the variable has not been Set
. Why is this not returning as Is Nothing
?
Here is the code:
If CCAddedGPSum Is Nothing Then 'Once here, ignores the test and continues to "END IF"
Set CCAddedGPSum = Range(CCGPSum.Offset(1, -3), CCGPSum.Offset(1, 1))
CCAddedGPSum.Insert shift:=xlDown
Set CCAddedGPSum = Range(CCGPSum.Offset(1, -3), CCGPSum.Offset(1, 1))
CCAddedGPSum.Interior.ColorIndex = 0
CCAddedGPSum.Insert shift:=xlDown
Set CCAddedGPSum = Range(CCGPSum.Offset(1, -3), CCGPSum.Offset(1, 1))
CCAddedGPSum.Interior.ColorIndex = 0
Set CCAddedGPTitle = Range(CCGPSum.Offset(1, -2), CCGPSum.Offset(1, -1))
With CCAddedGPTitle
.MergeCells = True
.HorizontalAlignment = xlRight
.VerticalAlignment = xlCenter
End With
CCAddedGPTitle.Value = "Removed from Deposit:"
Set CCAddedGPSum = CCGPSum.Offset(1, 0)
If CCAddedGPSum2 Is Nothing Then
CCAddedGPSum.Borders(xlEdgeBottom).LineStyle = xlContinuous
End If
If CCGPSum.Offset(-1, 0).Text = "" Then
Set CCGPSubtotal = CCGPSum
Set CCGPSum = CCAddedGPSum.End(xlDown).Offset(1, 0)
Range(CCGPSum.Offset(0, -1), CCGPSum.Offset(0, -2)).MergeCells = True
CCGPSum.Offset(0, -1).HorizontalAlignment = xlRight
CCGPSum.Offset(0, -2).Value = "Total:"
CCGPSum.Interior.ColorIndex = 6
End If
End If