Good Day Everyone, and Happy new year
I am having a small problem with the below code
What I am trying to do:
When i double lick a row in the listbox, I want to remove that line from the row Source
Problem:
This is removing lines from the source but it is removing the first line, this is due to the .listindex being returned as 0
Can anyone help, this is prob something really stupid that i have missed
Thanks in advance
I am having a small problem with the below code
What I am trying to do:
When i double lick a row in the listbox, I want to remove that line from the row Source
Problem:
This is removing lines from the source but it is removing the first line, this is due to the .listindex being returned as 0
Can anyone help, this is prob something really stupid that i have missed
Thanks in advance
Code:
Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim lastrows As Long
lastrows = Sheet9.Cells(Rows.Count, 49).End(xlUp).Row
Dim strRange As String
With ListBox2
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
Range(strRange).Cells(.ListIndex + 1, 16).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 17).Delete shift:=xlUp
Range(strRange).Cells(.ListIndex + 1, 18).Delete shift:=xlUp
.RowSource = vbNullString
.RowSource = strRange
End With
End Sub