+ Reply to Thread
Results 1 to 18 of 18

listbox properties behavior

  1. #1
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    listbox properties behavior

    I'm no Excel guru folks, but this issue I've searched for quite a bit and I'm not sure if this is a typical MS issue or not. There is some VBA here too. I am creating a very simple UF interface, and here is the code I have to throw data to a list box:

    Please Login or Register  to view this content.
    this works fine and I'm sure there are other ways to do this same thing. However, my question is about the ROWSOURCE, COLUMN WIDTHS and COLUMN HEADS properties . They seem to be very finicky and unreliable, which is something I've noticed with MS's office products. I am simply trying to throw sheet data into the column heads, then add items one by one, as indicated by the code. Most of it works fine. But I'd like to set the properties manually so I don't have to write lines of code. In this day in age, the writing of code is being minimized so much, I assume I can do that too in this instance. Can anyone assist here? I've gotten numerous errors, such as "invalid rowsource property" when typing in ""Sheet1!A1:L1"" into the properties argument. Google says this is fine. thanks.

    Adam

  2. #2
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: listbox properties behavior

    See the yellow banner at the top of this page.

  3. #3
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: listbox properties behavior

    thanks for the tip. by the way, was that yellow message at the top pasted just for me? I've never seen that before. was that done by an admin? I would have posted a sample file before, but I suppose my question was a little unclear. forgive me. I'm not a fan of microsoft tools of anykind. =)

    this is a xlsm file. the code will run when you open the book.
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: listbox properties behavior

    was that yellow message at the top pasted just for me?
    No - it's there for everyone, but personalised with your user name.

    We prefer you to attach .xlsm files rather than .zip files, as members can be understandably wary of opening these.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: listbox properties behavior

    so you want me to change it AGAIN? sure. I guess. google blocks everything. VBS, even zipped up.

  6. #6
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: listbox properties behavior

    this better?
    Attached Files Attached Files

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: listbox properties behavior

    Nobody is asking you to change anything - you can completely ignore us, if you like, but if you aren't open to advice, then you may not attract the help you need. We are trying to help you towards a resolution. Thanks for attaching an .xlsm file.

    Google blocks everything. VBS, even zipped up.
    We aren't Google - we are ExcelForum.

    .zip files are used to distribute malicious code, so some members will be wary of anything in that format.
    Last edited by AliGW; 07-04-2020 at 02:19 AM.

  8. #8
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: listbox properties behavior

    the yellow message was unclear, ma'am. that's all I'm saying. I have no idea what is up to date, what is hot, what is not, and such. I deal with people all day long that get scammed, but none of them download files. so I had no idea that zip's are used in this manner. scamming and viruses never end.

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: listbox properties behavior

    Listbox column headers only work with the rowsource method of loading.
    You have to specify individual column widths - setting width to zero hides the column but the data is there.
    Please Login or Register  to view this content.
    note between quotation marks
    If you load with 'rowsource' method then proceed to filter as you are doing with 'additem' method you will find that everything becomes unstable as the 'rowsource' is constantly reading your worksheet.
    Your rowsource should not be contained by quotation marks.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: listbox properties behavior

    Quote Originally Posted by vba_php View Post
    the yellow message was unclear, ma'am. that's all I'm saying. I have no idea what is up to date, what is hot, what is not, and such. I deal with people all day long that get scammed, but none of them download files. so I had no idea that zip's are used in this manner. scamming and viruses never end.
    I'm sorry you found it unclear. It asks for a SMALL Excel file and explains how to create that file and attach it - as sample files are small, there should never be any need to zip them. I just wanted to advise you that posting a .zip file will prevent some helpers from looking at it. Just trying to help you to get help, that's all, as you are new here and in the process of learning how things work.

  11. #11
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: listbox properties behavior

    Quote Originally Posted by torachan View Post
    Listbox column headers only work with the rowsource method of loading.
    what do you mean by "method of loading"?

    Quote Originally Posted by torachan View Post
    If you load with 'rowsource' method then proceed to filter as you are doing with 'additem' method you will find that everything becomes unstable as the 'rowsource' is constantly reading your worksheet.
    do your words refer to hard coding to the rowsource into the box's properties or dynamically setting it code, like in your example code?

  12. #12
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: listbox properties behavior

    Rowsource has many unpleasant features. Use .list to fill a listbox. You can adjust all settings in the design of the form. Also use a table then you always have a dynamic range.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: listbox properties behavior

    Vraag,

    considering what it says here: https://docs.microsoft.com/en-us/off....databodyrange

    I ran this:
    Please Login or Register  to view this content.
    and saw it. the real book has hundreds of thousands of rows in it. wouldn't my original method of filtering the data run faster than your code, considering that you are looping everything and skipping one val only? can you tell me what RESIZE(, 10).value does? I couldn't find that in MS docs. thanks.

  14. #14
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: listbox properties behavior

    the site below explains far better than i can the weaknesses of rowsource and advises best methods.
    personally i nearly always use tables within any apps I develop, they are very versatile and almost self-maintaining.
    Attached your file expanded with the method that I would adopt.

    Attached Files Attached Files

  15. #15
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: listbox properties behavior

    thanks much tora! i will get back to you if I run into anything.

  16. #16
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: listbox properties behavior

    Your method of filtering and using .add is the slowest you can use. How fast a loop goes into memory depends on your system. Optionally, you can use the advanced filter to create and use a temporary table.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  17. #17
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: listbox properties behavior

    ok you guys. i have plenty to work with. you did a little more work than i was expecting. thanks much. i will return with what I find and do.

  18. #18
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: listbox properties behavior

    This may be the other way around because nothing is deleted.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ 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. Userform Listbox Strange Behavior
    By CraigsWorld in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-13-2018, 08:06 PM
  2. ActiveX listbox behavior with frozen panes
    By ABSTRAKTUS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2018, 06:41 AM
  3. Listbox and behavior.
    By coyotenorth in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2014, 02:39 PM
  4. Strange listbox updating behavior
    By ahartman in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-13-2009, 11:27 AM
  5. Listbox - multiselectmulti properties
    By marcospaterson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2007, 09:53 AM
  6. [SOLVED] erratic listbox behavior
    By Mark Olsen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2006, 09:20 AM
  7. LISTBOX PROPERTIES
    By browie in forum Excel General
    Replies: 1
    Last Post: 08-22-2005, 12:05 PM

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