It does work when I try it.
But even simpler, you can replace those two lines with
Cells.EntireRow.Hidden = False
Delete & Unfilter
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Delete & Unfilter
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2347
- Joined: 23 Feb 2010, 12:07
Re: Delete & Unfilter
Does the code delete any two rows that you select from the list box and unhide the hidden rows?
Best Regards,
Adam
Adam
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Delete & Unfilter
The line of code from my previous reply will unhide all rows. It doesn't delete any rows, you already have working code for that.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2347
- Joined: 23 Feb 2010, 12:07
Re: Delete & Unfilter
The two codes you have provided does unhide after deleting the selected row. My intention is to delete multiple rows as from beginning. The cord works well if a single row is selected.
My intention is to select multiple rows when the listbox gets filtered and among them to select couple of rows. Delete them and unhide the rows.
My intention is to select multiple rows when the listbox gets filtered and among them to select couple of rows. Delete them and unhide the rows.
Best Regards,
Adam
Adam
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- SilverLounger
- Posts: 2347
- Joined: 23 Feb 2010, 12:07
Re: Delete & Unfilter
What I meant is that addition of the line
Cells.EntireRow.Hidden = False
does delete the selected row from the list box and unhide the hidden row. This works very well if a single row is selected from the list box.
But if I select multiple rows from the list box, the code does not seem to delete and unhide all the rows that I select from the list box.
I've set the Multiselect property of the list box to 1-fmMultiSelectMulti so that I could select multiple rows from the listbox.
But still I cannot make it work.
I hope I have made my question clear.
Cells.EntireRow.Hidden = False
does delete the selected row from the list box and unhide the hidden row. This works very well if a single row is selected from the list box.
But if I select multiple rows from the list box, the code does not seem to delete and unhide all the rows that I select from the list box.
I've set the Multiselect property of the list box to 1-fmMultiSelectMulti so that I could select multiple rows from the listbox.
But still I cannot make it work.
I hope I have made my question clear.
Best Regards,
Adam
Adam
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Delete & Unfilter
That line of code does not, repeat NOT delete any rows.
The code in Post=21229 earlier in this thread should correctly delete rows if multiple items have been selected in the list box.
The code in Post=21229 earlier in this thread should correctly delete rows if multiple items have been selected in the list box.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2347
- Joined: 23 Feb 2010, 12:07
Re: Delete & Unfilter
Yes Hans the code in Post=21229 does delete the rows, if multiple items have been selected in the list box. but it does not unhide the hidden rows.
So I had asked how to unhide the rows after deleting the rows and the final line you had given me was the line at Post=21266.
After the addition of the line from Post=21266 the code does delete only one row or does not delete either row but does unhide the hidden rows as you told.
What I'm trying to do is both. To delete the multi selected rows and unhide the hidden rows.
So I had asked how to unhide the rows after deleting the rows and the final line you had given me was the line at Post=21266.
After the addition of the line from Post=21266 the code does delete only one row or does not delete either row but does unhide the hidden rows as you told.
What I'm trying to do is both. To delete the multi selected rows and unhide the hidden rows.
Best Regards,
Adam
Adam
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Delete & Unfilter
Could you post the latest version of the code or the workbook?
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2347
- Joined: 23 Feb 2010, 12:07
Re: Delete & Unfilter
I've not made any changes to the workbook. It is as same as that of at Post=21228.
But the code is as follows,
But the code is as follows,
Code: Select all
Private Sub CommandButton_Remove_Click()
Dim i As Long
For i = Me.ListBox2.ListCount - 1 To 0 Step -1
If Me.ListBox2.Selected(i) Then
With Range("Data").SpecialCells(xlCellTypeVisible)
.Rows(i + 1).Delete
End With
End If
Next i
Cells.EntireRow.Hidden = False
FilterList
End Sub
Best Regards,
Adam
Adam
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Delete & Unfilter
It turned out to be mor complicated than I thought. I won't bother you with the reasons.
I have added a hidden column to the listbox that lists the row numbers of the items. This hidden column is used to determine which rows should be deleted.
See the attached version.
I have added a hidden column to the listbox that lists the row numbers of the items. This hidden column is used to determine which rows should be deleted.
See the attached version.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2347
- Joined: 23 Feb 2010, 12:07
Re: Delete & Unfilter
Thanks for the help Hans. The code now works fine. And I do really appreciate for the help you had given.
Meanwhile, congrats as Netherlands are through to semi-finals of 2010.
Meanwhile, congrats as Netherlands are through to semi-finals of 2010.
Best Regards,
Adam
Adam