+ Reply to Thread
Results 1 to 28 of 28

populate textbox from a listbox when data contains either decimals or cel properties

Hybrid View

  1. #1
    Registered User
    Join Date
    03-12-2012
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    14

    populate textbox from a listbox when data contains either decimals or cel properties

    2 problems i want to get out of the way...

    My first problem is on how to nicely align the data in a listbox. My code appears to be wrong even when i can't see any mistake what so ever???
    Maybe i am overlooking something, which i think will probably the case... You'll find my example attached.
    (To use it correctly you'll need to make a folder called "test" on you local C: drive an place some random *.txt files with different name lengths in it.)

    2nd problem: I am looking for a way on how to populate a textbox with data from a listbox that has been populated by a dynamic range.
    Actually i got this to work, except when the value in my lisbox contains either decimals 0,00 (comma) or if the data contains special cel properties,
    like 0 "pc" or 0 "mm" at the end of the value.

    I made a small test file on where you can find both problems shown. (see attachment) test.xlsm

    If anyone could help me out, i would be very grateful!
    Thanks in advance!!!

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: populate textbox from a listbox when data contains either decimals or cel properties

    Hi

    Couple of thoughts for 2nd problem.

    1) Add an en extra column that can be hidden, that has the row of the source. That way you will know where it comes from, so don't have to do the find.

    2) As don't seem to have any formatting on the first item (aluminium sheet) it seems to do the find successfully. From that find, you can get the row of the data (rng.row). So you don't really need to do any more finds, and you could use that will the cell(row,column) approach to knowing where the data is and can action accordingly.

    HTH

    rylo

  3. #3
    Registered User
    Join Date
    03-12-2012
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: populate textbox from a listbox when data contains either decimals or cel properties

    Hey Rylo,

    I like your way of thinking! I could indeed force the outcome in the way you propose, however i am wondering if this is really the only solution possible?
    I'll keep it in mind but would love to see on how it can be done without having to "cheat"! And what about a value with decimals, it will look a little silly if i provide another column for decimals only...
    As i said, this is a great backup plan though!

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: populate textbox from a listbox when data contains either decimals or cel properties

    Hi djeetn069
    I haven't tested the code thoroughly but it has been tested.
    Please note that I've changed ListBox to three columns to get the alignment. I've also set Rng3, Rng4 and Rng5 to look at
    LookAt:=xlPart
    in the Subtract/Add Button Codes. Let me know of issues.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    03-12-2012
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: populate textbox from a listbox when data contains either decimals or cel properties

    Hi John,

    Concerning the problem I had with the alignment of the populated listbox, this works exactly as I want now, so thanks a lot!
    The second problem hasn't been solved with the proposed solution though. The problem remains if a part of the value from the first "Lookat:= XlPart" is defined elsewhere, for instance: select the last row in "test v2.xlsm" and try to add 1pc. You'll notice that it will change the dimensions value of the row above.
    I've also noticed that the problem also remains when i try to add a pc to the 1,5mm thick sheet. My best guess, because of the decimal number... you'll notice a msgbox "material not found"...Any more ideas?

    Your help is much appreciated!
    Sincerely,

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: populate textbox from a listbox when data contains either decimals or cel properties

    Hi djeetn069
    Does your actual worksheet have the same structure (number of columns, etc) and layout as your attached sample (column headers, etc)?

  7. #7
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: populate textbox from a listbox when data contains either decimals or cel properties

    Hi

    I'm not saying that these are the only ways to do it - just ways I can think of to do it. You don't need to have another column for the decimals, as once you have the row number (regardless of which of the above methods you use to get it), then you know where all the items are in the source sheet.

    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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