Hi to all,
I have the following issue. Say for example that I have in Sheet1 the following A1: title and A2:A11 a named range called test_range
I have made Userform1 that contains Listbox1 and command button Delete
I have used .RowSource to populate the items of the listbox and I have also set the listbox to be multiselect.
I want to select one or more items in the listbox and upon pressing delete I want the respective cells in the named range to have a zero value.
I have the following code but it deletes only the first of the selected items and not all of them.
Any help would be handy... thanks in advance
Code:Private Sub Delete_Click() Dim strRange As String With ListBox1 strRange = .RowSource For I = 0 To .ListCount - 1 If .Selected(I) = True Then Range(strRange).Cells(I + 1, 1).Value = 0 End If Next .RowSource = vbNullString .RowSource = strRange End With End Sub
Bookmarks