Consulting

Results 1 to 16 of 16

Thread: Solved: List box value from an active cell.

  1. #1
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location

    Solved: List box value from an active cell.

    Hi, I have a user form with 3 list boxes, in List box 1 I want to show the value from the active cell on the related spread sheet in List box 2 I want to show the value from cell offset C2 to the active cell and in List box 3 I want to show the value from cell offset C3 to the active cell. I have tried to use various row source VBA codes but have failed to get it right.
    Any help would be much appreciated.
    I am working with Windows Home Premium version 6.1.7601 SP 1 Build7601and Excel version 14.0.6123.5001 (32 bit)
    Regards, Peter.

  2. #2
    VBAX Tutor
    Joined
    Jun 2012
    Posts
    269
    Location
    Please post example of workbook.

  3. #3
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location
    Hi, Thanks for looking at this.
    I have attached a reduced sample of my worksheet.
    When a user wants to add an order he selects the row he is adding to and then clicks the Add Order button which opens the user form.
    On this form I want to show the Name B/S and Code of the row selected in list boxes 1,2 and 3.
    The active cell is the name selected in Column C.
    Attached Files Attached Files
    Regards, Peter.

  4. #4
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    Your attachment doesn't have any userform in it.
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  5. #5
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location
    Sorry, here is the correct version.
    Attached Files Attached Files
    Regards, Peter.

  6. #6
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,638
    Use the list property to populate a combobox/listbox

  7. #7
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    Here you are. I also updated your initial code so that if someone isn't clicking column C it gives them a warning since you said they need to be clicking column C. By the way the activecell is no longer in column 3 once your code runs so the offset is from the first column.
    Attached Files Attached Files
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  8. #8
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location
    Hi BrianMH,
    Thank you very much, working as required.
    Regards, Peter.

  9. #9
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location
    Quote Originally Posted by snb
    Use the list property to populate a combobox/listbox
    Hi SNB,
    Can you please explain in more detail as I would like to use the list property but have failed to use it correctly,
    Regards,
    Peter
    Regards, Peter.

  10. #10
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    Do you actually need a listbox? It looks like you are using them as textboxes anyway.
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  11. #11
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,638
    see the attachment
    Attached Files Attached Files

  12. #12
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location
    Hi BrianMH,
    I couldn't see that a textbox would load with info from the spread sheet so using a listbox was my option.
    Regards, Peter.

  13. #13
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location
    Hi SNB,

    Thank you for your amended user form.
    I will get back once I have had a chance to look at it, sorry for any delay in answering
    Regards, Peter.

  14. #14
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    Ah I see. Well you can read the spreadsheet with VBA and then assign the text box values.
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  15. #15
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location
    Thanks BrianMH, I will give it a try.
    Regards, Peter.

  16. #16
    VBAX Contributor
    Joined
    Nov 2012
    Location
    Billericay, Essex
    Posts
    145
    Location
    Hi SNB.
    Yes I can now see what you mean, much better code, thank you.
    Regards, Peter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •