I have a listbox with 15 columns that is linked to a rowsource.
Private Sub cmdremove_Click()
Sheets("Database").Select
Dim lastrows As Long
lastrows = Sheets("Database").Cells(Rows.Count, 2).End(xlUp).Row
Dim strRange As String
With listdata
strRange = .RowSource
Range(strRange).Cells(.ListIndex + 1, 1).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 2).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 3).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 4).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 5).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 6).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 7).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 8).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 9).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 10).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 11).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 12).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 13).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 14).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 15).Delete shift:=xlUp
.RowSource = vbNullString
.RowSource = strRange
End With
Me.listdata.RowSource = Sheets("Database").Range("B6:L" & lastrows).CurrentRegion.Address
End Sub
It doesn't work properly and I was wondering if there is a method where the entire from in the rowsource can be deleted.
Thanks in advance!!
Bookmarks