Results 1 to 4 of 4

I'm receiving a Run-Time error 1004 while trying to delete a product from a product list.

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    I'm receiving a Run-Time error 1004 while trying to delete a product from a product list.

    I'm in the process of writing User Form code for a new project. Right now I'm writing the moduel to Add and Delete a product list, but it gives me an application-defined or object-defined error. Does any one know what I have done worng? I have highlighted in red where the error occurs. Hopefully, if I get past this error, my code will delete the product from the list!
    Private Sub cmdDelete_Click()
        
        Dim x As Integer
        Dim lRow As Long
        Dim lProduct As Long
        Dim sProduct As String
        Dim ws As Worksheet
        Set ws = Worksheets("LookupList")
    
    'find first empty row in database
        lRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
        SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
    
        lProduct = Me.cboProduct.ListIndex
        sProduct = Me.cboProduct.Value
    
    'check for a part number
        If Trim(Me.cboProduct.Value) = "" Then
            Me.cboProduct.SetFocus
            MsgBox "Please enter a Product Number"
            Exit Sub
        End If
        For x = 1 To lProduct
            If ws.Cells(x, 0).Value = sProduct Then
                 ws.Cells(x, 0).EntireRow.Delete
    'clear the data
                 Me.cboProduct.Value = ""
                 Me.cboProduct.SetFocus
                 Unload Me
                 Exit Sub
            End If
        Next x
    'if you get this far then the item you are trying to delete is not in the list.  This should never happen!
        MsgBox "Item not in list!"
    
    
    End Sub
    Thanks for your help! I have attached a copy of the spreadsheet.
    redsab
    Attached Files Attached Files
    Last edited by redsab; 07-05-2014 at 09:08 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 06-20-2014, 03:38 PM
  2. How to use RANGE Statment - Receiving Error 1004
    By efisher in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 01-13-2014, 01:14 PM
  3. Produce Product list by product category
    By barnowl in forum Excel General
    Replies: 2
    Last Post: 01-03-2013, 05:57 PM
  4. [SOLVED] Find Product Details in Another Sheet based on Product ID and Copy some Fields From there
    By kevalkothari in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2012, 10:43 AM
  5. [SOLVED] Need Function that will find ordered product, and display the product code in a 2nd workbk
    By rollerden in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2012, 08:52 AM

Tags for this Thread

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