howdy,
can anyone tell me how to fix this small issue i have with the following code?
i want the error execute to run if a row of the listbox is not highlighted (clicked On) at the moment it will erase the first row of listbox if proceded
with.
Private Sub CommandButton2_Click()
Dim irow As Long
Dim Cell As Range
If ListBox1.Value = "" Then
GoTo Err_Execute
Else
End If
Answer = MsgBox("Are you sure you want to remove job number " & ListBox1.Value, vbOKCancel, "Remove Job From Schedule")
If Answer = vbCancel Then Exit Sub
irow = ListBox1.ListIndex + 1
With ThisWorkbook.Sheets("schedule")
.Rows.EntireRow(irow + 1).Copy
Worksheets("Completed jobs").Range("A65536").End(xlUp).Offset(1, 0) _
.PasteSpecial Paste:=xlPasteValues
.Rows.EntireRow(irow + 1).Delete
End With
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
LoadlistBox
Exit Sub
Err_Execute:
MsgBox "Please highlight job to be removed."
End Sub
Bookmarks