Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9076239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:04:02+00:00 2026-06-16T19:04:02+00:00

My list box is on a form. When a user selected list items they

  • 0

My list box is on a form. When a user selected list items they are stored in a column. Later when m edit button is clicked I would like to read in these values and add them onto a selected list (Listbox_selectedCategories) on the form and remove them from the other list box (Listbox_categories) The error that the VBA editor is throwing is error 381 could not get list property. Invalid property array index. I have checked both the value of x and index in the immediate window which are iterating as expected.I have also tried this without the Cstr function,same error. The compiler is highlighting the if statement as the point of error. Im sure this is some fundamental misunderstanding I would appreciate any help or direction. Thanks.

 Public Sub dataLoad()
 Dim x As Integer
 x = 0

NewQueryForm.targetingDescription.value = ActiveCell.Offset(1, 0).value
NewQueryForm.booleanDescription.value = ActiveCell.Offset(1, 1).value
NewQueryForm.startDate.value = ActiveCell.Offset(1, 3).value
NewQueryForm.endDate.value = ActiveCell.Offset(1, 4).value
NewQueryForm.dfpCount.value = ActiveCell.Offset(1, 5).value

NewQueryForm.Text_300Rates = ActiveCell.Offset(1, 8).value

NewQueryForm.Text_160Rates = ActiveCell.Offset(2, 8).value

NewQueryForm.Text_728Rates = ActiveCell.Offset(3, 8).value

NewQueryForm.Text_PollRates = ActiveCell.Offset(4, 8).value

NewQueryForm.Text_CMRates = ActiveCell.Offset(5, 8).value

NewQueryForm.Text_ExCMRates = ActiveCell.Offset(6, 8).value



Call NewQueryForm_Initialize

Sheets("CAT").Activate
Range("A1").Activate
ActiveCell.Offset(0, loopCount).Activate

While ActiveCell.Offset(1, 0).value <> ""
x = x + 1
Dim index As Integer

'Adding and removing items from list
NewQueryForm.ListBox_selectedCategories.AddItem ActiveCell.Offset(x - 1, 0).value

For index = 0 To NewQueryForm.ListBox_categories.ListCount - 1

If CStr(NewQueryForm.ListBox_categories.List(index)) = ActiveCell.Offset(x - 1, 0).value Then
            NewQueryForm.ListBox_categories.RemoveItem (index)
        End If

Next index

'Adding and Subtracting from global percent label variables
selectedCategoryLabel = selectedCategoryLabel + categoryPercent(ActiveCell.Offset(x - 1, 0).value)
categoryLabel = categoryLabel - categoryPercent(ActiveCell.Offset(x - 1, 0).value)

'Setting next cell down active
ActiveCell.Offset(1, 0).Activate
Wend

'updating labels
 NewQueryForm.selectedPercent.Caption = CStr(Round(selectedCategoryLabel, 2)) & "%"
 NewQueryForm.categoryPercent = CStr(Round(categoryLabel, 2)) & "%"





NewQueryForm.Show
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:04:03+00:00Added an answer on June 16, 2026 at 7:04 pm

    Following is the code I tried. I got the exact same error. And here is how I solved it.

    BINGO: EXIT THE LOOP 🙂

    Option Explicit    
    '--show form on Sheet with Reg Edit mode
     Private Sub CommandButton1_Click()
        UserForm1.Show vbModeless
     End Sub   
    
    '--Form codes within Form
    
    Option Explicit
    
    Private Sub cmdAddRange_Click()
    Dim ws As Worksheet
    Dim rng As range
    Dim inputArray As Variant
    Dim lRow As Long
    Dim index As Integer
    
    Set ws = Sheets(1)
    Set rng = ws.range("B2")
    lRow = ws.range("B" & ws.Rows.Count).End(xlUp).Row
    inputArray = Application.WorksheetFunction.Transpose(rng.Resize(lRow).Value)
    
    'Adding item to List one by one from Array
    'For index = LBound(inputArray) To UBound(inputArray)
    'UserForm1.ListBox1.AddItem inputArray(i)
    'Next i
    
    'Adding items to List box at ones from Array
    UserForm1.ListBox1.List = inputArray
    UserForm1.ListBox2.List = inputArray
    
    End Sub
    
    Private Sub cmdRemoveRange_Click()
    Dim ws As Worksheet
    Dim index As Integer
    
        Set ws = Sheets(1)
    
        '-- Remove  from listbox1
        For index = 0 To UserForm1.ListBox1.ListCount - 1
    
            If Not IsEmpty(ActiveCell.Value) Then
                If UserForm1.ListBox1.List(index) = ActiveCell.Value Then
                    UserForm1.ListBox1.RemoveItem (index)
                    MsgBox ActiveCell.Value & " deleted. And Golden Line *Exit For*"
                    Exit For '-- golden line
                End If
            End If
        Next index
    
    End Sub
    

    Here is the Form I tried out:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used Multiple select Box in edit form, displaying previously selected items in
The user sees a form with many controls, including a list box. He selects
Setup: A form with a text box, a button, and a list box. The
I have a html form which have a select list box from which you
I have a ListBox on a WPF form. I would like to display a
I have a list box like this, <asp:ListBox ID=ListBox1 runat=server Height=175px Width=213px> <asp:ListItem Value=all>All</asp:ListItem>
Have a PHP/MySQL form with a dropdown box containing a list of 350 names.
I have a User control with a list box . This User control located
I have a list of Payees in a drop down box on my form.
I have a form with a select list and if the item the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.