Question about active cell offset

Private Sub SecondSort()

Dim value As String, address As String

value = “”
address = “”

Range(“B30000”).Select
Selection.End(xlUp).Select
Let value = ActiveCell.value
Let address = ActiveCell.address

Do While address <> “$B$2”
address = ActiveCell.address
value = ActiveCell.value

If value = “Projected” Then

ActiveCell.Rows(“1:1”).EntireRow.Select

Selection. Delete Shift:=xlUp
ActiveCell.Offset(-1, 0).Range(“B1”).Select
address = ActiveCell.address

Else

ActiveCell.Offset(-1, -1).Range(“B1”).Select

End If

Loop

End Sub

I’ve got a question about the macro above. It’s working, but, I’m not sure why. It’s my understanding that when using ActiveCell.Offset the first value in parenthesis is the desired row offset and the second number is the desired column offset. The “ActiveCell.Offset(-1, 0).Range(“B1″).Select” inside the IF statement is behaving as expected. However, if I use the same line of code in the Else statement, it moves up one row and one column to the right. I’m having to use “ActiveCell.Offset(-1, -1) to force to move one row up while remaining in column B.

Being brand new to VBA, I would welcome advice or guidance.

Participant Asked on August 27, 2018 in VBA.
Add Comment
0 Answer(s)
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.