+ Reply to Thread
Results 1 to 16 of 16

Remove Button for ListForm Trasnfer - need to unselect on original listform

  1. #1
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Remove Button for ListForm Trasnfer - need to unselect on original listform

    I have 2 listforms. User can select on listform1 and click ADD to transfer to listform2.

    I also have a REMOVE button. It removes it from listform2.

    BUT what I would like for it to do, in addition to, is to unselect it on listform1 as well.

    I can't seem to formulate the right code:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,657

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    This will deselect the Listbox1 selection if that's what you're asking.

    ListBox1.ListIndex = -1
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Hmm - I tried but the selected item on Listbox2 is still selected on Listbox1.
    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,657

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Quote Originally Posted by o4008 View Post
    Hmm - I tried but the selected item on Listbox2 is still selected on Listbox1.
    Please Login or Register  to view this content.
    Can you show your event procedures for both ListBox1 and ListBox2 ?

  5. #5
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Please Login or Register  to view this content.

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

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  7. #7
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Thank you so much Norie!!! - but now my problem becomes, how do I redirect the code to read from listbox2 and transfer applicable data? If you read my prior code - the selection on listbox1 is the one that is being transferred to the excel sheet.

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

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Eh, wouldn't that just mean replacing ListBox1 with Listbox2 here?
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Thought that, but now, listbox2 is unselected. Not only that - for some reason I get an error. Must be how I set up the transfer. UGH..

    What I'm trying to do, is
    1. Have listbox1 (Apple, Orange, Cherry) --- User chooses Apple and Orange --- it transfers it to listbox2 for review
    2. User decides I don't want Apple --- user selects apple on listbox2 --- clicks remove button --- removes apple from listbox2 and also deselects it from listbox1
    3. user clicks another button - this button reads from selected items on listbox1 --- and starts transfering to excel sheet

    Sorry - first time using userforms. And I tried to step, but can't do it modally.
    Last edited by o4008; 07-29-2013 at 02:29 PM.

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

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Don't check for what's selected in ListBox2,loop through the list - everything in it has already been 'selected' from ListBox1.

  11. #11
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    I'm confused

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

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    You've selected items in ListBox1 and transferred them to ListBox2.

    So now everything in ListBox2 is what you selected from ListBox1, so you don't need to check what's selected in ListBox2.
    Please Login or Register  to view this content.
    Last edited by Norie; 07-29-2013 at 04:07 PM.

  13. #13
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    Ahh.. Works - but now, I don't have the full data on listbox2. How do I transfer the array? I have 38 columns.
    <code>
    Sub AddButton_Click()
    Dim i As Long

    For i = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(i) Then
    ListBox2.AddItem ListBox1.list(i)
    ListBox1.Selected(i) = False
    End If
    Next i

    End Sub
    </code>

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

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    How are you populating ListBox1 and where does the data come from?

  15. #15
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    On the properties, I listed a data table as a rowsource.

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

    Re: Remove Button for ListForm Trasnfer - need to unselect on original listform

    First, can I ask why you have the 2nd listbox?

    If you only used one listbox this would be straightforward.

+ 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. [SOLVED] Remove formula and leave original value
    By DeanP in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2013, 08:47 AM
  2. Trasnfer information to new worsheet
    By smetcalfe in forum Excel General
    Replies: 1
    Last Post: 02-17-2013, 10:19 AM
  3. remove duplicate AND its original rows
    By TAX in forum Excel General
    Replies: 4
    Last Post: 03-29-2012, 02:12 AM
  4. To remove duplicates and get the cell-address of the original
    By Sagar.Ghole in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-12-2008, 10:30 PM
  5. Remove duplicate and original
    By Backdoor Cover in forum Excel General
    Replies: 4
    Last Post: 06-08-2006, 08:40 PM

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