When the last row of information is deleted from the listbox via the "Delete" button the listbox gets the following error...
"Run-time error '380': Could not set the RowSorce propert. Invalid property value."
[VBA]Private Sub cmdDel_Click()
With frmRequest.ListBox1
'Check for selected item
If (.Value <> vbNullString) Then
'If more then one data rows
If (.ListIndex >= 0 And xlLastRow("Leave Request") > 2) Then
Range(.RowSource)(.ListIndex + 1, 1).EntireRow.Delete
'Update listbox
.RowSource = "'Leave Request'!A2:E" & xlLastRow("Leave Request")
'If only one data row
ElseIf (.ListIndex = 0 And xlLastRow("Leave Request") = 2) Then
Range(.RowSource)(.ListIndex + 1, 1).EntireRow.Delete
'Update listbox
.RowSource = "'Leave Request'!A2:E"
End If
Else
MsgBox "Please Select Data"
End If
End With
End Sub[/VBA]
The columns in the listbox are Name, Requested, Type, Start, and End. Once the listbox reloads the columns are set to Column A, Column B Column C, Column D, and Column E and the the first row in the listbox is Name, Requested, Type, Start, and End. How can I keep this from happening and keep the columns set as Name, Requested, Type, Start, and End???
Issue number two; how can I have the listbox update immediately after information is added, removed or edited via the userform "frmRequest".
Issue number three; if the last row of information is deleted from the listbox and then a new row is added this new information doesn't fill the Edit Selection form, "UserForm4"???
Best regards,
Charlie