Listbox Scroll problem

DeathSurfer

New Member
Joined
Mar 21, 2007
Messages
15
Duuuuudes:

I have a problem with scrolling to the bottom of a listbox in excel '03. I'm using the listbox control in vba, not the excel forms control. Anyway, when I scroll to the bottom of the list, it won't let me see the last item in the list box. It will stop one short and will actually have a space below the scroll bar that looks like it could scroll down one more list item but won't. I'm using the additem call to populate the listbox. I've tried recreating the listbox and it will work the first time it gets populated but seems like after repopulating it a couple times it will cause the problem. Can anyone shed some light on why this would be doing this?

Here's the code for populating the listbox:

Code:
'repopulate the lbdate listbox
For i = 1 To wsfd.Range("FD_InProcDateData").Count
    TempDate = wsfd.Range("FD_InProcDateData").Cells(i).Value
    TempDay = Weekday(TempDate)
    Select Case TempDay
    'sunday for facility x
    Case 1
        With wsr.Range("R_Location")
            Worksheets("Report").lbdate.AddItem TempDate & "        " & "V"
        End With
    'monday thru friday for facility y
    Case 2 To 6
        With wsr.Range("R_Location")
            Worksheets("Report").lbdate.AddItem TempDate & "        " & "BC"
        End With
    'saturday for facility z
    Case 7
        With wsr.Range("R_Location")
            Worksheets("Report").lbdate.AddItem TempDate & "        " & "D&D"
        End With
    End Select
    'skip to next date
    Do
        i = i + 1
    Loop Until wsfd.Range("FD_InProcDateData").Cells(i).Value <> TempDate Or i = wsfd.Range("FD_InProcDateData").Count
    'if i equals the range count then exit the for statement. if this isn't done, the last schedule date will show twice.
    If i = wsfd.Range("FD_InProcDateData").Count Then
        Exit For
    End If
    'backup a cell because of the next i statement
    i = i - 1
Next i
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
This is the basic code to fill a Controls listbox in a worksheet.
Code:
Sub FillListBox()
    Dim DataSheet As Worksheet
    Dim MyList As Range
    Dim FileListBox As Object
    Dim i As Integer            ' listbox item
    Dim rw As Long              ' worksheet row
    '---------------------------------------------------------
    Set DataSheet = Worksheets("data")
    Set MyList = DataSheet.Range("FileList")
    Set FileListBox = ActiveSheet.ListBox1
    '---------------------------------------------------------
    FileListBox.Clear
    rw = 1
    '- loop
    For i = 0 To MyList.Rows.Count - 1
        FileListBox.AddItem
        FileListBox.List(i) = MyList.Cells(rw, 1).Value
        rw = rw + 1
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,552
Messages
6,114,278
Members
448,560
Latest member
Torchwood72

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top