Results 1 to 2 of 2
  1. #1
    Thompyt is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Post Simpler Code

    Is there a simpler way to make an array list other than Adding in all the values line by line?




    Code:
    Option Explicit
    Dim ARRV2 as ArrayList
    
        Set ArrV2 = New ArrayList
          
        ArrV2.Add "zz"        '0
        ArrV2.Add "A"         '1
        ArrV2.Add "B"         '2
        ArrV2.Add "C"         '3
        ArrV2.Add "D"         '4
        ArrV2.Add "E"         '5
        ArrV2.Add "F"         '6
        ArrV2.Add "G"         '7
        ArrV2.Add "H"         '8
        ArrV2.Add "J"         '9
        ArrV2.Add "K"         '10
        ArrV2.Add "L"         '11
        ArrV2.Add "M"         '12
        ArrV2.Add "N"         '13
        ArrV2.Add "P"         '14
        ArrV2.Add "HHB"       '15
        ArrV2.Add "HHC"       '16
        ArrV2.Add "HHT"       '17
        ArrV2.Add "HHBN"     '18
        ArrV2.Add "COY"      '19
        ArrV2.Add "MAIN"     '20
        ArrV2.Add "TAC"       '21
        ArrV2.Add "HSMCC"  '22
    Something like this?

    ArrV2 = Array("A", "B", "C",............... "HSMCC", "HHB", "HHC")

    With
    Set ArrV2 = New ArrayList
    ArrV2 = Array("A", "B", "C",............... "HSMCC", "HHB", "HHC")


    I get Runtime Error 5, without Set ArrV2 = New ArrayList Error 91 - with object variable or with block variable not set.

    The ArrV2.Add " it works.


    I can use the following way as a list filter:
    Worksheets(1).Range("H1").AutoFilter Field:=8, Criteria1:=Array("FE", "MTOE", "PH", "PARA", "PLAT"), Operator:=xlFilterValues

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Do you mean you want an Array object?

    Dim ArrV2 As Variant
    ArrV2 = Split("A,B,C,...............,HSMCC,HHB,HHC", ",")

    Never mind, I can see now that you don't.

    Looks like you have the appropriate solution with .Add method.

    I tried testing your code in Excel and found out need to set reference to mscorlib.dll library.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 07-27-2016, 03:02 AM
  2. Replies: 3
    Last Post: 10-16-2014, 08:49 AM
  3. Replies: 7
    Last Post: 05-28-2013, 09:11 AM
  4. Replies: 1
    Last Post: 05-04-2013, 12:19 PM
  5. Which Export to Excel Method is Simpler to Implement?
    By Heatshiver in forum Import/Export Data
    Replies: 16
    Last Post: 03-26-2012, 07:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums