Results 1 to 20 of 20

Can't delete names that are all numbers in userform listbox.

Threaded View

  1. #1
    Registered User
    Join Date
    06-18-2014
    Location
    Houston, TX
    MS-Off Ver
    2010
    Posts
    63

    Can't delete names that are all numbers in userform listbox.

    Hello all! In this macro I can't delete names that are all numbers via the userform. I can delete names that are mixes of letters and numbers just not all numbers (e.g 123123123). Any help on fixing this would be greatly appreciated! I am attaching the file for convenience.

    The error in debug pinpoints the line that i am underlining in the following code.

    Private Sub CommandButtonDeleteUpdate_Click()
    
    
    'use RemoveItem method to delete a ListBox row. The below code deletes the row from the
    'ListBox and also deletes the row items (or rows) in the worksheet
        Dim n As Long
        Dim k As Long
        Dim var As Variant
    
    
        'deleting row from ListBox using RemoveItem method:
    
        'check all items in a ListBox; reverse order (Step -1) is used because rows are being deleted from ListBox.
        For n = ListBoxDeletePickSiteList.ListCount - 1 To 0 Step -1
    
            If ListBoxDeletePickSiteList.Selected(n) = True Then
    
                'item to be deleted is stored in the variable named var
                var = ListBoxDeletePickSiteList.List(n, 0)
                ListBoxDeletePickSiteList.RemoveItem (n)
    
    
                'determine row number in which items are to be deleted; Note: value of variable named var
                'is derived from first column, hence Range("A:A") is searched in the Match formula.
                k = Application.Match(var, Worksheets("Site List").Range("B:B"), 0)
    
                'delete the row to the corresponding item in listbox
                Worksheets("Site List").Rows(k).Delete
    
                Exit For
    
            End If
    
        Next n
    
        'Refresh list
        LoadListBoxDeletePickSiteList
        LoadComboBoxEditSiteName
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Userform Delete from Listbox and cell
    By jasonmcbee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2014, 09:45 PM
  2. [SOLVED] Can add listbox control to userform, but cannot delete!
    By perducci in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2013, 02:03 PM
  3. Delete record from listbox via Userform
    By Jonathan78 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-19-2011, 03:31 AM
  4. UserForm freezes after delete from Listbox
    By NewExcelVBA in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-28-2011, 02:34 PM
  5. Fill A Userform Listbox With Names OF All Open Workbooks
    By JR@SGC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2007, 05:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1