+ Reply to Thread
Results 1 to 9 of 9

Export listbox items to worksheet horizontally

  1. #1
    Registered User
    Join Date
    10-07-2015
    Location
    Breda
    MS-Off Ver
    2013
    Posts
    6

    Export listbox items to worksheet horizontally

    Hello everyone,

    I’m trying to export items from a listbox to a worksheet.
    The code I’m using gives me the items in a vertically order, but I need the items in a horizontally order starting at the 3e column at the first row.
    I have tried the following code:

    Dim TheArray As Variant
    Dim TheRange As Range
    TheArray = ListBox2.List
    Set TheRange = Blad10.Range(Blad10.Cells(1, 3), Blad10.Cells(1, 3 + UBound(TheArray))
    TheRange = TheArray
    End Sub

    Thank you in advance!

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

    Re: Export listbox items to worksheet horizontally

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

  3. #3
    Registered User
    Join Date
    10-07-2015
    Location
    Breda
    MS-Off Ver
    2013
    Posts
    6

    Re: Export listbox items to worksheet horizontally

    Quote Originally Posted by Norie View Post
    Try this.
    Please Login or Register  to view this content.
    Thanks for the fast response!
    I'm getting error 13 type mismatch

  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: Export listbox items to worksheet horizontally

    It works for me when I use arbritary data.

    When you get the error what's in the listbox?

  5. #5
    Registered User
    Join Date
    10-07-2015
    Location
    Breda
    MS-Off Ver
    2013
    Posts
    6

    Re: Export listbox items to worksheet horizontally

    I have a list of textual data....
    I'm getting the error on this line : TheRange = Application.Transpose(TheArray)

  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: Export listbox items to worksheet horizontally

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  7. #7
    Registered User
    Join Date
    10-07-2015
    Location
    Breda
    MS-Off Ver
    2013
    Posts
    6

    Re: Export listbox items to worksheet horizontally

    See sample in attachment

    The code belongs to sheet4 (Blad4)
    Last edited by heldenbreda; 10-08-2015 at 02:55 AM.

  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: Export listbox items to worksheet horizontally

    Try this.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-07-2015
    Location
    Breda
    MS-Off Ver
    2013
    Posts
    6

    Re: Export listbox items to worksheet horizontally

    It works perfectly! Thank you very much

+ 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. Copy items from listbox to worksheet range
    By gsurge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-03-2014, 10:08 AM
  2. [SOLVED] VBA: transfer values of textboxes & items from listbox to worksheet
    By hydz1213 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-19-2013, 05:46 AM
  3. Transfer random listbox items to new listbox and then loop through selected items
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2013, 05:58 PM
  4. Adding multiple items from listbox to worksheet...
    By aneese11 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2012, 10:57 AM
  5. [SOLVED] Move Listbox items up and down (ActiveX on a worksheet)
    By ABSTRAKTUS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-20-2012, 05:18 AM
  6. Write Items from listbox to worksheet
    By efernandes67 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2011, 06:15 AM
  7. ListBox items paste into worksheet in reverse order
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2006, 01:19 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