+ Reply to Thread
Results 1 to 11 of 11

Put a selected row into a listbox in a userform

  1. #1
    Forum Contributor
    Join Date
    05-07-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    122

    Smile Put a selected row into a listbox in a userform

    hello everybody!

    I am new using recently vba, i have a problem concerning a listbox!

    I have an excel sheet with names.
    my macro ask with an input which name do you want to delete.
    Once you've put the name and press ok the entire row with the name and other informations is selected and the 'delete' userform opens.
    I want to show in a listbox the selected row so the user see it and is sure to delete the right row!
    Everything works in my macro except the listbox!

    Can someone help me please!!?
    Thank you!!Macro sebastien.xlsm

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Put a selected row into a listbox in a userform

    1. change the columncount of the listbox to 3
    2. change the Idelete code to
    Please Login or Register  to view this content.
    you could also do it without copying any data
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Contributor
    Join Date
    05-07-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Put a selected row into a listbox in a userform

    Thank you for your fast response! I tried your code and they tell me there is an error on : " vRow = Application.Match(CLng(SN), Range("C:C"), 0)"
    I notices that you didn't write dim vRow as.... is it right like this?
    Does it work on your pc?

  4. #4
    Forum Contributor
    Join Date
    05-07-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Put a selected row into a listbox in a userform

    And how could you do this thing without copying? I'm trying since yesterday at work and it doesn't work!!!
    Thank you for your help!!

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Put a selected row into a listbox in a userform

    are your serial numbers actually numbers like in your example? if not use
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    05-07-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Put a selected row into a listbox in a userform

    no i am actually using the code that i sent to you for another macro, i am just trying this feature on a small example you can put names instead of serial numbers!!

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Put a selected row into a listbox in a userform

    to load the list without copying
    Please Login or Register  to view this content.
    again remove the CLng if your SN is not numeric

  8. #8
    Forum Contributor
    Join Date
    05-07-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Put a selected row into a listbox in a userform

    It's not working sorry!
    Do you have an example where it works?

  9. #9
    Forum Contributor
    Join Date
    05-07-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Put a selected row into a listbox in a userform

    IN fact with this code the selected row appears in the listbox:


    Please Login or Register  to view this content.
    Now when I select in the listbox the item i want it to take the value and delete the row!
    How cna i do that ?

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Put a selected row into a listbox in a userform

    here's your workbook with working code

    to delete with your code you can use
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    05-07-2013
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    122

    Re: Put a selected row into a listbox in a userform

    Quote Originally Posted by JosephP View Post
    here's your workbook with working code

    to delete with your code you can use
    Please Login or Register  to view this content.
    THANK YOU VERY MUCH!! Everything is working now!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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