Consulting

Results 1 to 5 of 5

Thread: Solved: Listbox Related Question

  1. #1

    Solved: Listbox Related Question

    Hello....I am a new member to this forum & also to visual basic for applications.

    I was trying the code for sorting the listbox items numerically as well as alphabetically.

    I tried the example from help menu to load the listbox and used a sortlistbox function that I found over the net.

    I am getting the items sorted but I am getting them shifted by one place downwards.

    For example if ListItem (0,0) is "zero" & ListItem (1,0) = "one", the situation before & after sorting is as follows:

    BEFORE SORTING

    row 0 zero
    row 1 one

    AFTER SORTING

    row 0 EMPTY
    row 1 one
    row 2 zero

    I need the values arranged as per alphabets but the places should not be changed.

    I need help for understanding & resolving the problem...I had attached a sample worksheet herewith.

    Thanks much!!

    Akshay

  2. #2
    VBAX Regular arangogs's Avatar
    Joined
    Jun 2009
    Location
    Ayrshire, Scotland
    Posts
    18
    Location
    Hi Akshay,

    I think this is what you are looking for, change your array declaration to

    Dim myArray(5,3)

  3. #3
    Hi arangogs,

    Thanks for your reply...I tried changing the array declaration & it worked!

    -- Akshay.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by arangogs
    Hi Akshay,

    I think this is what you are looking for, change your array declaration to

    Dim myArray(5,3)
    Or maybe even (5,2)?

    Akshay,
    Welcome to VBAX,
    You can mark your thread Solved using the Thread Tools dropdown.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Regular arangogs's Avatar
    Joined
    Jun 2009
    Location
    Ayrshire, Scotland
    Posts
    18
    Location
    yeah, missed that there, mate

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •