Results 1 to 16 of 16

adding items to an array

Threaded View

Code Flunkie adding items to an array 08-11-2016, 12:16 PM
AB33 Re: adding items to an array 08-11-2016, 12:33 PM
Code Flunkie Re: adding items to an array 08-11-2016, 01:54 PM
AB33 Re: adding items to an array 08-11-2016, 02:28 PM
Code Flunkie Re: adding items to an array 08-11-2016, 03:02 PM
AB33 Re: adding items to an array 08-11-2016, 03:09 PM
Code Flunkie Re: adding items to an array 08-11-2016, 04:08 PM
AB33 Re: adding items to an array 08-11-2016, 04:16 PM
Code Flunkie Re: adding items to an array 08-11-2016, 04:49 PM
AB33 Re: adding items to an array 08-11-2016, 04:54 PM
Code Flunkie Re: adding items to an array 08-11-2016, 05:02 PM
jindon Re: adding items to an array 08-11-2016, 06:05 PM
Code Flunkie Re: adding items to an array 08-12-2016, 08:46 AM
AB33 Re: adding items to an array 08-11-2016, 05:19 PM
jindon Re: adding items to an array 08-12-2016, 06:41 PM
Code Flunkie Re: adding items to an array 08-15-2016, 02:07 PM
  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    adding items to an array

    I have a listbox that breaks down a comma delimited list from a single column and lists the individual items for a user to select, which is then fed back to an autofilter to hide the rows that don't contain the items anywhere in the cell. ie

    a2 = cat, dog, mouse
    a3 = cat, mouse
    a4 = dog, mouse
    a5 =dog
    a6 =dog

    if user selects "dog" the array cycles through the cells that contain dog and should add them to the array. so a2, a4, a5 should be added. a6 should be ignored because it would already be in the array. my code seems to be adding a6 as well so it seems to slow the code down because it's adding to many duplicates. i'm sure it's a simple syntax error on my part but i cant seem to find it. any help would be awesome.

          Set rng = Range(CatCol & "1:" & CatCol & LastRow)
           
            For j = 1 To LastRow
            
            
            cellv = UCase(Range(CatCol & j))
                
                For i = LBound(MyArray) To UBound(MyArray)
                    If Not IsEmpty(MyArray(i)) Then
                        If InStr(UCase(Range(CatCol & j)), UCase(MyArray(i))) Then
                            If UCase(Range(CatCol & j)) <> UCase(MyArray(i)) Then
                                MyArray(UBound(MyArray)) = Range(CatCol & j)
                                ReDim Preserve MyArray(UBound(MyArray) + 1)
                            End If
                        End If
                    End If
                    
                Next i
            Next j
    Last edited by Code Flunkie; 08-15-2016 at 02:10 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help with finding items in a List and adding items not found
    By DawaiDost in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-29-2016, 10:56 AM
  2. Replies: 4
    Last Post: 05-26-2016, 09:30 AM
  3. [SOLVED] How to keep items in ListBox in alphabetical order when removing and adding items to box
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-31-2015, 07:13 AM
  4. [SOLVED] Looping through dictionary items where items are an array
    By strud in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2014, 06:56 AM
  5. loop in combobox for adding new sheets when adding new items
    By tnkcoll in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2012, 08:27 PM
  6. find each of the items in an array and save result in another array
    By lif in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2006, 08:54 PM
  7. Adding Items to an array
    By musictech in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2005, 03:05 PM

Tags for this Thread

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.6.0 RC 1