+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    03-14-2010
    Location
    lima, peru
    MS-Off Ver
    Excel 2003
    Posts
    3

    Unhappy List box scroll bar - Display last entry

    Hi friends,
    I need a syntax to dislplay my last entry in a list box.
    every time I enter a new data; it goes all the way to the bottom and I can't see
    my last entry. It'll be nice to see my last entries at the beginig of the list!
    Hope anyone can help. I've been strugeling a long time with this Problem!

  2. #2
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: List box scroll bar - Display last entry

    How are you adding to the ListBox entries?
    Where is the ListBox
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  3. #3
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    2,929

    Re: List box scroll bar - Display last entry

    I'm not sure what you are asking.
    To add a new item to the top of a list box, use the Item argument of .AddItem
    Code:
    ListBox1.AddItem "new item", 0
    To scroll a listbox to a spot in the list, the .TopIndex property should be used.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    03-14-2010
    Location
    lima, peru
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: List box scroll bar - Display last entry

    Quote Originally Posted by mikerickson View Post
    I'm not sure what you are asking.
    To add a new item to the top of a list box, use the Item argument of .AddItem
    Code:
    ListBox1.AddItem "new item", 0
    To scroll a listbox to a spot in the list, the .TopIndex property should be used.
    Thank you for helping; I'm curretly using 2007 excel and I'm created my own POS system using VBA coding for my Mom store. The problem is when she keeps entering products it disapears on the bottom of the list an she can't see the last entries and so she has to force it with the mouse
    to be able to see it.
    I typed the line you provided but i didn't work

    Private Sub ListBox1_Click()
    ListBox1.AddItem "new item", 0
    End Sub


    I used top index, but it does't work either.
    the Rowsource i have it as C10:G30 under List box Properties menu!

    sorry for creating so much trouble. I promesed her to fix it by her birth day. it just one of those things!

  5. #5
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    2,929

    Re: List box scroll bar - Display last entry

    How does she "enter a product"?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    3,556

    Re: List box scroll bar - Display last entry

    HI ferrete

    If you can post your workbook so we can see what's happening, I'm fairly certain someone on this forum can solve your issue by
    by her birth day
    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  7. #7
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: List box scroll bar - Display last entry

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  8. #8
    Registered User
    Join Date
    03-14-2010
    Location
    lima, peru
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: List box scroll bar - Display last entry

    Quote Originally Posted by mikerickson View Post
    How does she "enter a product"?
    I'm using this syntax to Input data , as she keeps putting code and quanity the info acumulates on the bottom of the list but when she keeps entering more products codes she can't longer see the last entries. It'll be nice the last entry show up always on the top of the list or the scrolling bar stays down to be able to see the last entry eather or would be just fine!
    I tried using topIndex on properties and got to force it down but every time I run the form the scroll bar ges back to the top again!

    Option Explicit

    Sub GetData()

    Dim NextRow As Long
    Dim Entry1 As String, Entry2 As String

    Do
    'Determine next empty row
    NextRow = Cells(Rows.Count, 3).End(xlUp).Row + 1


    ' Prompt for the data
    Entry1 = InputBox("Codigo")
    If Entry1 = "" Then Exit Sub

    Entry2 = InputBox("Cantidad")
    If Entry2 = "" Then Exit Sub

  9. #9
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    3,556

    Re: List box scroll bar - Display last entry

    Hi ferrete

    I see you're new to the Forum. You probably won't get too many responses until you follow RoyUK's admonishment in Post #7. USE CODE TAGS. Also, post a sample of your workbook.

    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0