{"id":14070697,"url":"https://github.com/cristianbuse/VBA-ArrayTools","last_synced_at":"2025-07-30T08:31:40.430Z","repository":{"id":53516213,"uuid":"264026221","full_name":"cristianbuse/VBA-ArrayTools","owner":"cristianbuse","description":"Easily manipulate Arrays and Collections in VBA (sorting, filtering, conversions and more)","archived":false,"fork":false,"pushed_at":"2024-03-21T09:53:38.000Z","size":9790,"stargazers_count":27,"open_issues_count":0,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-13T07:18:14.506Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"VBA","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cristianbuse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"cristianbuse"}},"created_at":"2020-05-14T21:12:22.000Z","updated_at":"2024-04-20T12:47:00.000Z","dependencies_parsed_at":"2024-08-13T07:17:42.942Z","dependency_job_id":null,"html_url":"https://github.com/cristianbuse/VBA-ArrayTools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristianbuse%2FVBA-ArrayTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristianbuse%2FVBA-ArrayTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristianbuse%2FVBA-ArrayTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristianbuse%2FVBA-ArrayTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cristianbuse","download_url":"https://codeload.github.com/cristianbuse/VBA-ArrayTools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228110718,"owners_count":17871216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:08:02.833Z","updated_at":"2024-12-04T12:32:02.032Z","avatar_url":"https://github.com/cristianbuse.png","language":"VBA","readme":"# VBA-ArrayTools\n\nArrayTools is a Project that allows easy data manipulation when working with Arrays and Collections in VBA (regardless of host Application). Operations like sorting, filtering, converting, reversing, slicing are trivial using the LibArrayTools module. Additionaly, a User-Defined-Function (UDF) module is available for Microsoft Excel.\n\n## Installation\n\nJust import the following code modules in your VBA Project:\n\n* **LibArrayTools.bas**\n* **UDF_DataManipulation.bas** (optional - works in MS Excel interface only, with exposed User Defined Functions)\n\n## Testing\n\nImport the folowing code modules:\n* **TestLibArrayTools.bas**\n* **frmTestResults.frm**\n\nand execute method:\n```vba\nTestLibArrayTools.RunAllTests\n```\n\n## Usage\nHere are a couple of demo method calls. Find more in the available Demo.bas module\n\nArray-Array conversions, Array-Collection conversions (and viceversa). Note that methods like 'NDArrayTo1DArray' support arrays up to 60 dimensions.\n```vba\nPublic Sub DemoConversions()\n    Dim coll As Collection\n    '\n    'Create a Collection from values\n    Set coll = Collection(1, 2, 3, 4, 5)\n    'Result:\n    '   [1,2,3,4,5]\n    '\n    Dim arr() As Variant\n    '\n    'Convert a Collection to a 1D Array\n    arr = CollectionTo1DArray(coll)\n    'Result:\n    '   [1,2,3,4,5,6]\n    '\n    'Convert a Collection to a 2D Array\n    arr = CollectionTo2DArray(coll, 3)\n    'Result:\n    '   [1,2,3]\n    '   [4,5,6]\n    '\n    'Convert 1D Array to a 2D Array\n    arr = OneDArrayTo2DArray(Array(5, 2, 1, 3, 6, 1, 9, 5), 2)\n    'Result:\n    '   [5,2]\n    '   [1,3]\n    '   [6,1]\n    '   [9,5]\n    '\n    arr = OneDArrayTo2DArray(Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 4)\n    Dim arr2() As Variant\n    '\n    'Convert 2D Array to 1D Array\n    arr2 = NDArrayTo1DArray(arr, rowWise)\n    'Result:\n    '   [1,2,3,4,5,6,7,8,9,10,11,12]\n    arr2 = NDArrayTo1DArray(arr, columnWise)\n    'Result:\n    '   [1,5,9,2,6,10,3,7,11,4,8,12]\n    '\n    'Convert 2D Array to nested Collections\n    Set coll = NDArrayToCollections(arr)\n    'Result:\n    '   [[1,2,3,4],[5,6,7,8],[9,10,11,12]]\n    '\n    'Merge two 1D arrays\n    arr = Merge1DArrays(Array(1, 2, 3), Array(4, 5))\n    'Result:\n    '   [1,2,3,4,5]\n    '\n    Dim arr1() As Variant\n    arr1 = OneDArrayTo2DArray(Array(1, 2, 3, 4), 2)\n    arr2 = OneDArrayTo2DArray(Array(5, 6, 7, 8), 2)\n    \n    'Merge two 2D arrays\n    arr = Merge2DArrays(arr1, arr2, False)\n    'Result:\n    '   [1,2,5,6]\n    '   [3,4,7,8]\n    arr = Merge2DArrays(arr1, arr2, True)\n    'Result:\n    '   [1,2]\n    '   [3,4]\n    '   [5,6]\n    '   [7,8]\n    '\n    'Transpose a 2D Array\n    arr = TransposeArray(arr1)\n    'Result:\n    '   [1,3]\n    '   [2,4]\nEnd Sub\n```\nArray and Collection advanced Filtering\n```vba\nPublic Sub DemoFiltering()\n    Dim arr() As Variant\n    Dim coll As Collection\n    Dim filters() As FILTER_PAIR\n    Dim boolExpression As Boolean\n    '\n    'Check if a value is passing a filter\n    boolExpression = IsValuePassingFilter(5, CreateFilter(opBigger, 3))          'True\n    boolExpression = IsValuePassingFilter(5, CreateFilter(opBigger, 7))          'False\n    boolExpression = IsValuePassingFilter(5, CreateFilter(opin, Array(1, 3, 5))) 'True\n    boolExpression = IsValuePassingFilter(\"test\", CreateFilter(opLike, \"?es?\"))  'True\n    boolExpression = IsValuePassingFilter(\"c\", CreateFilter(opLike, \"[a-d]\"))    'True\n    '\n    'Create array of filters\n    filters = CreateFiltersArray(\"\u003e\", 1, \"\u003c=\", 5, \"NOT IN\", Array(3, 4))\n    '\n    'Filter a 1D Array\n    arr = Filter1DArray(Array(1, 2, 3, 4, 5), filters)\n    'Result:\n    '   [2,5]\n    '\n    arr = OneDArrayTo2DArray(Array(5, 2, 1, 3, 6, 1, 9, 5), 2)\n    filters = CreateFiltersArray(\"IN\", Array(1, 3, 5, 7, 9))\n    '\n    'Filter a 2D Array\n    arr = Filter2DArray(arr, 0, filters)\n    'Result:\n    '   [5,2]\n    '   [1,3]\n    '   [9,5]\n    arr = Filter2DArray(arr, 1, filters)\n    'Result:\n    '   [1,3]\n    '   [9,5]\n    '\n    'Filter a Collection\n    Set coll = FilterCollection(Collection(\"A\", \"B\", \"C\", \"D\", \"E\") _\n        , CreateFiltersArray(\"LIKE\", \"[B-E]\", \"NOT LIKE\", \"[C-D]\"))\n    'Result:\n    '   [\"B\",\"E\"]\nEnd Sub\n```\nInformation functions related to Arrays/Collections\n```vba\nPublic Sub DemoGetInformation()\n    Dim coll As New Collection\n    Dim boolExpression As Boolean\n    '\n    coll.Add 6, \"Key1\"\n    '\n    'Check if a Collection has a key\n    boolExpression = CollectionHasKey(coll, \"Key1\") 'True\n    boolExpression = CollectionHasKey(coll, \"Key2\") 'False\n    '\n    Dim arr() As Variant\n    Dim arr2D(0 To 2, 0 To 3) As Variant\n    Dim arr3D(1 To 3, 1 To 2, 1 To 5) As Variant\n    Dim arr4D(1 To 2, 1 To 3, 1 To 4, 1 To 5) As Variant\n    Dim dimensionsCount As Long\n    Dim elementsCount As Long\n    '\n    'Get the number of dimensions for an array\n    dimensionsCount = GetArrayDimsCount(7)       '0\n    dimensionsCount = GetArrayDimsCount(arr)     '0\n    dimensionsCount = GetArrayDimsCount(Array()) '1\n    dimensionsCount = GetArrayDimsCount(arr2D)   '2\n    dimensionsCount = GetArrayDimsCount(arr3D)   '3\n    dimensionsCount = GetArrayDimsCount(arr4D)   '4\n    '\n    'Get the number of elements for an array\n    elementsCount = GetArrayElemCount(5)              '0\n    elementsCount = GetArrayElemCount(arr)            '0\n    elementsCount = GetArrayElemCount(Array(1, 5, 6)) '3\n    elementsCount = GetArrayElemCount(arr2D)          '12\n    elementsCount = GetArrayElemCount(arr3D)          '30\n    elementsCount = GetArrayElemCount(arr4D)          '120\n    '\n    'Check if a variant support For...Each loop\n    boolExpression = IsIterable(arr)     'False\n    boolExpression = IsIterable(Array()) 'True\n    boolExpression = IsIterable(coll)    'True\n    boolExpression = IsIterable(Nothing) 'False\nEnd Sub\n```\n\n## Notes\n* Argument Descriptions in the Function Help for the Excel Function Arguments Dialog (fx on the formula bar or Shift + F3) are available by running:\n```vba\nUDF_DataManipulation.RegisterDMFunctions\n```\n* Download the available Demo Workbook. Each UDF is presented with examples in a separate worksheet.\n\n## License\nMIT License\n\nCopyright (c) 2012 Ion Cristian Buse\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","funding_links":["https://github.com/sponsors/cristianbuse"],"categories":["VBA"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristianbuse%2FVBA-ArrayTools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcristianbuse%2FVBA-ArrayTools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristianbuse%2FVBA-ArrayTools/lists"}