LOOP function VBA

Hi I'm new and trying to learn VBA.

I am trying to make my code so that when A2 has some text in it, A1 displays "X" until A1="Y" (then the code stops).
But my code doesn't seem to be working and is causing excel to crash... Maybe it's too long?

My code is:

Sub test2()
Worksheets(2).Range("A1").Select
Do
If Not IsEmpty(ActiveCell.Offset(0, 1).Value) Then
ActiveCell.Value = "X"
ActiveCell.Offset(1, 0).Select

End If
Loop While Not ActiveCell.Value = "Y"
End Sub

Thanks a bunch

Nick's picture

Loop While Not

Loop While Not ActiveCell.Value = "Y"

- if ActiveCell.Value is never Y, then this code will never end