Why is code unexpectedly stopping?

goldenvision

Board Regular
Joined
Jan 13, 2004
Messages
234
I am running the code below to select a record in a list box on a userform then search through records until a match is found and mark the matched record with an "x". However the code seems to be stopping part way through and I can't figure out why. Any help would be greatly appreciated. (Code marked with comments below)

Code:
Private Sub lst_DeleteLeaveRequest_Click()
Dim i As Long, x
Dim leaveID As Integer
Dim rowCount As Integer
rowCount = 1

With Me.lst_DeleteLeaveRequest
    For i = 0 To .ListCount - 1
        If .Selected(i) Then
             leaveID = .List(i, 0)
MsgBox leaveID
        End If
    Next
End With
'++++THIS IS THE POINT WHERE THE CODE STOPS++++
Do Until Cells(rowCount, 1) = ""
If Cells(rowCount, 1).Value = leaveID Then
Cells(rowCount, 6).Value = "x"
Else
End If

rowCount = rowCount + 1
Loop
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Are their blank fields where you are running the code? as Excel will stop counting the second it comes to a blank cell.
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top