+ Reply to Thread
Results 1 to 16 of 16

Using the same theory of code but use a dropdown list instead of Radio Buttons

  1. #1
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Using the same theory of code but use a dropdown list instead of Radio Buttons

    Hi All,

    I would like to know if it's possible:

    I have a Listbox that is populated by a spreadsheet via a OptionButtons. IE:

    Please Login or Register  to view this content.
    There are 8 option buttons and each populates the listbox with data ranging from two rows up to 10 rows.

    The List style is fmListStyleOption

    I would like that when the user selects the box that the contents of that box be copied to the clipboard so it can be pasted into another application.


    Best Regards

    John
    Last edited by JJFletcher; 10-23-2015 at 07:11 PM.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Copy to clipboard the Userform listbox item selected

    Hello JJFletcher,

    Difficult, for me at least, to provide you with a ready answer, without a sample Workbook.

    But you could try to add the below to your code:

    Please Login or Register  to view this content.
    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Copy to clipboard the Userform listbox item selected

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Copy to clipboard the Userform listbox item selected

    When added to the code - indicates


    Runtime error '2147024809 80070057)
    DataObject:SetText Invalid argument

    this was for this code offered:

    Please Login or Register  to view this content.
    Last edited by JJFletcher; 10-17-2015 at 03:25 PM.

  5. #5
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Copy to clipboard the Userform listbox item selected

    Kenneth..

    your solution provides data - it actually copies the entire Column of data...

    When the user selects a row and the box has a check in it - Only that row of data should be copied - Almost there

    Best Regards,

    John
    Last edited by JJFletcher; 10-17-2015 at 03:23 PM. Reason: grammer

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

    Re: Copy to clipboard the Userform listbox item selected

    John

    How do you want the selected items/rows in the listbox to be put on the clipboard?

    As some sort of delimited list?
    If posting code please use code tags, see here.

  7. #7
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Copy to clipboard the Userform listbox item selected

    Private Sub OptionButton1_Click()
    Me.ListBox1.RowSource = "B12:B20"
    Range(ListBox1.RowSource).Copy
    End Sub

    This does copy , but the entire 8 rows

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Copy to clipboard the Userform listbox item selected

    The DataObject requires the MSForms reference to be added in the Tools menu.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Copy to clipboard the Userform listbox item selected

    Hi Norie,

    Just the row that the user has selected from the ListBox - when the user selects the row they want the box is checked

    image2.jpg

  10. #10
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Copy to clipboard the Userform listbox item selected

    Kenneth - You are so close... I added the 8...

    Please Login or Register  to view this content.
    It is only copying the first row of the eight in this set

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

    Re: Copy to clipboard the Userform listbox item selected

    I thought you were selecting multiple items?

    Are you sure you don't have MultiSelect set to fmMultiSelectMulti?

  12. #12
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Copy to clipboard the Userform listbox item selected

    It is set to fmMultiSelectMulti

    As illustrated in the image above - the user can select from any of eight choices - and what ever they select in the box is what needs to be copied to the clipboard
    Last edited by JJFletcher; 10-17-2015 at 04:03 PM.

  13. #13
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Copy to clipboard the Userform listbox item selected

    Obviously it will always pick the first row since you updated the rowsource and then used my code. Use the Listbox's Click event to copy the row selected.

    If your are going to use mulitselect, then a different solution is needed.

  14. #14
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Copy to clipboard the Userform listbox item selected

    Here is my multiselect method. I used the Exit event to run the copy.
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Using the same theory of code but use a dropdown list instead of Radio Buttons

    Have changed the Post header - because the need has changed from the Radio buttons to a dropdown list that the user will select instead and the data will show as it does in the text box. Any Idea's or samples I can review?

    Best Regards,

    John

  16. #16
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Using the same theory of code but use a dropdown list instead of Radio Buttons

    Hi JJFletcher,

    Sorry, but I am not exactly sure of your requirement and/or if your workbook contains a Userform.

    For the lack of same as explained above, I hope that the attached Workbook will suffice.

    Regards.
    Attached Files Attached Files

+ 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 - Getting Sheet row of selected item
    By johnny_p in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2015, 05:00 AM
  2. [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
  3. Selected item in first listbox.
    By waka in forum Access Tables & Databases
    Replies: 1
    Last Post: 02-09-2015, 11:45 PM
  4. [SOLVED] listindex=0 when first item selected in a multiselect listbox on a userform?
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-17-2013, 12:38 PM
  5. Replies: 0
    Last Post: 07-03-2012, 01:06 AM
  6. Keep selected ListBox item highlighted when reopening userform
    By berlini in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2011, 08:38 AM
  7. How to copy selected listbox item to sheet
    By michdan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2005, 08:05 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