+ Reply to Thread
Results 1 to 7 of 7

VBA Listbox add item function

Hybrid View

  1. #1
    Registered User
    Join Date
    11-24-2015
    Location
    Poland
    MS-Off Ver
    10
    Posts
    75

    VBA Listbox add item function

    Hey,

    I'm perplexed... Why doesn't the code work? Error message: object required

    Sub Button13_Click()
    
    ListBox21.AddItem Range("E167").Value
    
    End Sub
    Last edited by moomphas; 05-30-2018 at 06:10 AM.

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: VBA Listbox add item function

    Hello
    May be the control "ListBox21" doesn't exist
    It would be better if you upload sample of your file
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Registered User
    Join Date
    11-24-2015
    Location
    Poland
    MS-Off Ver
    10
    Posts
    75

    Re: VBA Listbox add item function

    Sample attached
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Listbox add item function

    Try this.
        Sheet1.ListBox21.ListFillRange = Range("E167:E167").Address
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    11-24-2015
    Location
    Poland
    MS-Off Ver
    10
    Posts
    75

    Re: VBA Listbox add item function

    Thanks! Works, but I will add more items from E167 (it's a drop down), so this way makes me unable to add more items.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA Listbox add item function

    Perhaps
    Sheet1.ListBox21.AddItem Range("E167").Value
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  7. #7
    Registered User
    Join Date
    11-24-2015
    Location
    Poland
    MS-Off Ver
    10
    Posts
    75

    Re: VBA Listbox add item function

    thanks, works

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] ListBox Array creates blank ListBox item
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-16-2019, 12:33 PM
  2. Select Listbox Item by ComboBox Item
    By atadaliran in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-10-2017, 04:04 PM
  3. vba excel - last listbox item transfer erasing all listbox items except last item
    By terriertrip in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-06-2017, 03:48 PM
  4. [SOLVED] VBA To populate listbox with duplicate item by increasing the item quantity
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-01-2016, 07:51 AM
  5. [SOLVED] if anything in listbox select first item, if listbox empty do nothing (listbox in userform
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 12:49 PM
  6. [SOLVED] Copy one listbox item to same index position in another listbox
    By Foreverlearning in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-19-2012, 06:05 AM
  7. Populate ListBox Based On Item Chosen In Another ListBox
    By davemojo82 in forum Excel General
    Replies: 1
    Last Post: 08-04-2009, 08:39 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