Hello excelforum community!
So,
I'm getting this error (the title) - "Object Variable or With Block Variable Not Set." I did some googling before posting here and it seems that this basically means I'm using an invalid variable (or the variable doesn't have a value). I declared all my variables right at the start and immediately set them equal to something.
I suspect the error is either with what I set my variables to, the operations I did with the variables later (such as: first = first.offset(4,0) ) or maybe something with a way I'm supposed to handle variables when their in nested Ifs or in nested Loops?(because I have both).
I'd really appreciate any insight anyone has into this.
If you have any questions just let me know! I can be as accommodating as you need.
Sub listHoldings()
Dim first As Range
Dim second As Range
Dim start As Range
first = Range("BL13")
second = Range("BM13")
start = Range("BR13")
start.Select
Do
Do
If ActiveCell.Value = "1" Then
first.Value = ActiveCell.Offset(-1, 0).Value
ActiveCell.Offset(0, 1).Select
Else
If ActiveCell.Value = "2" Then
second.Value = ActiveCell.Offset(-1, 0).Value
Else
ActiveCell.Offset(0, 1).Select
End If
End If
Loop Until IsEmpty(first) = False And IsEmpty(second) = False
first = first.Offset(4, 0)
second = second.Offset(4, 0)
start = start.Offset(4, 0)
Loop Until IsEmpty(first.Offset(0, -3))
End Sub
Bookmarks