Excel VBA - ArrayList (Sort, Reverse and Clone Methods)

Опубликовано: 25 Март 2026
на канале: The World Of Algorithms
5,300
like

ArrayList in Excel VBA is a class used to create an array of values. ArrayList is more flexible than native array because it's dynamic and it contains much richer functionality. It is in an external library.

Let's answer a few questions about ArrayList.

❓ 1️⃣ How to create the ArrayList ?
👉 You can create the ArrayList using early and late binding

❓ 2️⃣ How to create the ArrayList using late binding ?
👉 There is no need to activate a special library for this. All you have to do is use the simple form below:

Dim arr_1 as Object (arr_1 is a variable used in the video)
Set arr_1 = CreateObject("System.Collections.ArrayList")

❓ 3️⃣ How to create the ArrayList using early binding ?
👉 To use this form, you need to perform several operations. These are those operations:

Step 1. Open the Viual Basic Editor (ALT+F11)
Step 2. Click Tools
Step 3. Click References
Step 4. Scroll down the list, tick the mscorlib.dll checkbox and click OK

After that, the following code should be written:

Dim arr_1 as new ArrayList (arr_1 is a variable used in the video)

❓ 4️⃣ How to sort the elements in ascending order using sort method ?
👉

Dim arr_1 as new ArrayList (early binding)
--------------------
--------------------
arr_1.Sort

❓ 5️⃣ How to sort the elements in descending order using sort method ?
👉 If you want to sort the array from highest to lowest, use Reverse method after Sort method.

Dim arr_1 as new ArrayList (early binding)
--------------------
--------------------
arr_1.Sort
arr_1.Reverse

❓ 6️⃣ How to create a copy of the original ArrayList ?
👉

Dim arr_1 as new ArrayList (early binding)
--------------------
--------------------
arr_1.Clone
------------------------------------------------------------------------------------------
Buy a Cofee ☕ for theworldofalgorithms: https://ko-fi.com/theworldofalgorithms

🥰Thank you for the donation. I am deeply grateful for your help!🥰
------------------------------------------------------------------------------------------

#excel
#msexcel
#vba
#excelvba
#microsoftexcel
#tutorial
#exceltutorial
#excelvbatutorial
#subprocedure
#vbasubprocedure
#excelvbasubprocedure
#arraylist
#vbaarraylist
#array
#arrays
#dynamic
#dynamicarray
#excelvbaarraylist
#arraylistinvba
#collection
#collections
#vbacollections
#vbatutorial
#mscorlib
#library
#dll
#tlb
#runtime
#multilanguagestandardcommonobjectruntimelibrary
#microsoftcommonobjectruntimelibrary