![]() |
How to delete item from listbox?
1 Attachment(s)
I got a userform where I'd like to delete selected items. Anybody has an idea how to?
|
How to delete item from listbox?
On Friday, October 19, 2012 3:39:03 PM UTC-4, questionguy wrote:
I got a userform where I'd like to delete selected items. Anybody has an idea how to? +-------------------------------------------------------------------+ |Filename: DeleteItem.zip | |Download: http://www.excelbanter.com/attachment.php?attachmentid=632| +-------------------------------------------------------------------+ -- questionguy Hi Try this: Private Sub cmddelete_Click() Dim msgResponse As String, c As Range Application.ScreenUpdating = False msgResponse = MsgBox("This will delete the selected record. Continue?", _ vbCritical + vbYesNo, "Delete Entry") Select Case msgResponse Case vbYes Set c = ActiveCell c.Delete Case vbNo Exit Sub End Select Application.ScreenUpdating = True End Sub |
Thanks for your reply. I inserted your code, everything seemed to work except it actually didn't delete anything. Was I doing something wrong?
---------------------- Hi Try this: Private Sub cmddelete_Click() Dim msgResponse As String, c As Range Application.ScreenUpdating = False msgResponse = MsgBox("This will delete the selected record. Continue?", _ vbCritical + vbYesNo, "Delete Entry") Select Case msgResponse Case vbYes Set c = ActiveCell c.Delete Case vbNo Exit Sub End Select Application.ScreenUpdating = True End Sub[/quote] |
How to delete item from listbox?
On Monday, October 22, 2012 9:39:00 AM UTC-4, questionguy wrote:
Thanks for your reply. I inserted your code, everything seemed to work except it actually didn't delete anything. Was I doing something wrong? ---------------------- Hi Try this: Private Sub cmddelete_Click() Dim msgResponse As String, c As Range Application.ScreenUpdating = False msgResponse = MsgBox("This will delete the selected record. Continue?", _ vbCritical + vbYesNo, "Delete Entry") Select Case msgResponse Case vbYes Set c = ActiveCell c.Delete Case vbNo Exit Sub End Select Application.ScreenUpdating = True End Sub +-------------------------------------------------------------------+ +-------------------------------------------------------------------+ -- questionguy Hi No You didn't do anything wrong, I did.I didn't try it on your WS Try this one. Private Sub cmddelete_Click() Dim msgResponse As String, c As Variant Application.ScreenUpdating = False msgResponse = MsgBox("This will delete the selected record. Continue?", _ vbCritical + vbYesNo, "Delete Entry") Select Case msgResponse Case vbYes c = listaccount.Value On Error Resume Next Columns("B:E").Find(What:=c, _ LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False).Activate Set c = ActiveCell If ActiveCell = Range("Purchaser_Info") Then c.Resize(1, 2).Clear Else c.Clear End If Case vbNo Exit Sub End Select Application.ScreenUpdating = True End Sub |
All times are GMT +1. The time now is 12:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com