Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On May 6, 9:42*am, Ayo wrote:
I get the above error in my code on line Me.ListBox2.Remove Item i. What I am attempting to do is remove any item from the ListBox2 in excess of 25 Item. In other words, if the user attempts to place 26 or more items in the ListBox a message is display and the excess items are removed. *This is my dilemma. Any help will be greatly appreciated. For i = 0 To ListBox1.ListCount - 1 * * * * If Me.ListBox1.Selected(i) = True And i <= 25 Then * * * * * * Me.ListBox2.AddItem ListBox1.List(i) * * * * ElseIf ListBox1.Selected(i) = True And i 25 Then * * * * * * MsgBox Msg, Style, Title * * * * * * Me.ListBox2.RemoveItem i * * * * * * Exit For * * * * End If * * Next i Ayo, I'm assuming your code is in the ListBox1_Click event. I'm also assuming that as the user selects an item from ListBox1, the item is populated into ListBox2. Once ListBox2 is populated to 25 items, you want an error message to fire letting the user know that ListBox2 is "full." You will find the code below to accomplish my stated assumptions. Best, Matthew Herbert Private Sub ListBox1_Click() Dim I As Integer 'fill ListBox2 and check if ListBox2 has 25 items With Me If ListBox2.ListCount <= 25 Then .ListBox2.AddItem .ListBox1.Value Else MsgBox Msg, Style, Title End If End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
"Compile Error: ByRef argument type mismatch" when calling my function from another module | Excel Programming | |||
Export to excel via webpage: "Invalid Procedure Call or Argument" | Excel Programming | |||
Pivot Table Creation Macro fails with Error #5 "Invalid procedure call or argument" | Excel Programming | |||
"ByRef argument type mismatch" Error | Excel Programming | |||
Invalid "format string" argument in Format fuction | Excel Programming |