+ Reply to Thread
Results 1 to 11 of 11

Moving multiple column rows between 2 listboxes

  1. #1
    Registered User
    Join Date
    08-22-2013
    Location
    Frome England
    MS-Off Ver
    Excel 2013
    Posts
    6

    Moving multiple column rows between 2 listboxes

    Hi

    I have a userform with 2 listboxss. One listbox contains Currency info with 13 columns in it. The first column specifies the currency (GBP, Euro etc) and the other 12 are decimal values for each of the 12 months.

    When the user double clicks a row I need to copy the complete row to the other listbox. It can go from right to left and left to right.

    Im using this code:

    If numCols > 1 Then
    For i = 1 To numCols - 1
    insertedItem = lstMoveTo.ListCount - 1
    lstMoveTo.List(insertedItem, i) = lstMoveFrom.List(itemIndex, i)
    Next i
    End If

    However only the first 10 columns are copied due to constraints on listboxes with unbound data sources.

    Any body have any ingenious ways to get round this?

    Thanks

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    First can I ask why you want to move the12 columns?

    What's the next step after you've done that?

    Does it involve choosing a month?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-22-2013
    Location
    Frome England
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Moving multiple column rows between 2 listboxes

    Hi Norie

    Columns in the left currency listbox are values saved into a sheet in the current xls.

    The listbox on the right are currency values coming in from a loaded xls.

    So i can remove currency entries from the current xls, or import as i wish from the import xls

    Cheers

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

    Re: Moving multiple column rows between 2 listboxes

    Sorry you've kind of lost me there.

    You have 2 listboxes each populated from a different workbook and you want to move data to and fro between them.

    Is that all you want to do?
    Last edited by Norie; 09-05-2013 at 09:44 AM.

  5. #5
    Registered User
    Join Date
    08-22-2013
    Location
    Frome England
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Moving multiple column rows between 2 listboxes

    Yeah thats it, quite simple !!

    apart from the fact you cant move more than 10 columns using ".item = " from one listbox to another !

    Thanks for your help

    Darren

  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: Moving multiple column rows between 2 listboxes

    Darren

    I know that's a problem and I'm kind of trying to think if there's a way round it by taking a slightly different approach.

    You can actually do it with arrays (or ranges) and List but that's a bit fiddly.

    Any chance you could upload a sample workbook?

  7. #7
    Registered User
    Join Date
    08-22-2013
    Location
    Frome England
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Moving multiple column rows between 2 listboxes

    Hi

    Cant send a worksheet as the code is created on the fly in a userform.

    But, heres the code to move the record between listboxes

    Please Login or Register  to view this content.
    Thanks

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

    Re: Moving multiple column rows between 2 listboxes

    Why does that stop you uploading a workbook?

  9. #9
    Registered User
    Join Date
    08-22-2013
    Location
    Frome England
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Moving multiple column rows between 2 listboxes

    Cause the real reason is that the xls has loads of confidential data and so does the workbook to import.

    I'm working on storing the MoveTo records and fields into an array, then adding the MoveFrom record and using the MoveTo.list to add them all back.

    If I cant get it working ill create a test xls in the morning and submit that.

    Thanks

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Moving multiple column rows between 2 listboxes

    if you populate with array you can exceed 10 columns and use the List array property.

    userform with 2 listboxes and a button to transfer selected list row from 1 to the other.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  11. #11
    Registered User
    Join Date
    08-22-2013
    Location
    Frome England
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Moving multiple column rows between 2 listboxes

    Hi Andy

    I got it working using the array method.

    Please Login or Register  to view this content.
    Thanks for the link though.

+ 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] Moving multiple rows into one row (1 record has 4 rows)
    By dogmaxi in forum Excel - New Users/Basics
    Replies: 8
    Last Post: 06-11-2013, 07:01 PM
  2. [SOLVED] Looping through rows in a column and the moving onto the next column
    By MoonWeazel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2012, 03:52 AM
  3. Replies: 2
    Last Post: 07-09-2012, 01:44 PM
  4. Replies: 5
    Last Post: 02-07-2012, 04:55 PM
  5. Moving groups of rows in one column to another column
    By sglosemeyer5 in forum Excel General
    Replies: 0
    Last Post: 02-01-2012, 02:55 PM

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