Results 1 to 4 of 4

List of items in a userform listbox, object required error in code

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-23-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    139

    List of items in a userform listbox, object required error in code

    Hi,

    I'm attempting modify some code from one userform to a new one, using different cell references from the original macro. I'm working at a level where I am beginning to understand VBA functions but I admit that this code is just a little bit beyond my understanding (it was previously given to me in this forum to help with the first listbox I put together).

    I've changed the code as best I can and am getting a "424 Object Required" error, where the ## is in the code below.

    I'm happy to give more detail as to the thing i'm trying to do but briefly, the user will change a combobox called CB_Name, then the code runs which will look for all the times that name is mentioned in COL P (of another sheet, not the activesheet), then list all of the Items in col B rows that contain that name. The current code below does this by using the "find" feature that excel has and using an offset of -14 columns after the initial "find all of that name" part - I think i've changed the cell references correctly but i can't think of why a previously working code has this error now.

        LB_Items.Clear
        Set rngLook = Range("p3:p" & Range("p40000").End(xlUp).Row)
        strValueToPick = CB_Name.Value
        With rngLook
            Set rngFind = .Find(strValueToPick, .Cells(1, 1), LookIn:=xlValues, lookat:=xlWhole)
            If Not rngFind Is Nothing Then
                strFirstAddress = rngFind.Address
                Set rngPicked = rngFind
                Do
                    Set rngPicked = Union(rngPicked, rngFind)
                    Set rngFind = .FindNext(rngFind)
                Loop While Not rngFind Is Nothing And rngFind.Address <> strFirstAddress
            End If
        End With
        
       ## If Not rngPicked Is Nothing Then
            rngPicked.Offset(0, -14).Select
            
            'Fill Listbox
            For Each c In Selection
            LB_Items.AddItem c.Value
            Next
            
        End If
    Last edited by jayherring86; 01-09-2015 at 05:45 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] 424 Object required error when calling a UserForm from another
    By rybussell in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2013, 01:16 PM
  2. [SOLVED] Why 'object required' error from this code?
    By vizzkid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2013, 09:35 AM
  3. [SOLVED] Items in Userform Listbox are wider than list box. Need to see all character of item
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2012, 06:40 AM
  4. Compile error : object required in userform
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2010, 04:08 AM
  5. Error 424 Object Required Error when Using AddItem to ListBox Generated in Code
    By jclark419 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2010, 12:47 PM

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