Issue adding items to an ArrayList

zoog25

Active Member
Joined
Nov 21, 2011
Messages
418
Hello All,

I'm trying to run a code and tried to use ArrayList but I'm having issues with adding items to the ArrayList. Here is the code i'm using.

VBA Code:
Public EArr as New ArrayList

Sub ExistArray()
Dim MAINws As Worksheet
Dim lrowMain As Long
Dim Cnt As Long
Dim Entry As String

Set MAINws = ThisWorkbook.Worksheets("Assessments")

lrowMain = MAINws.Cells(Rows.Count, "C").End(xlUp).Row

For Cnt = 2 To lrowMain
    Select Case Len(MAINws.Cells(Cnt, "C"))
        Case 11
            Entry = MAINws.Cells(Cnt, "C").Value
            EArr.Add Entry
        Case 10
            Entry = "0" & CStr(LCase(MAINws.Cells(Cnt, "C")))
            EArr.Add Entry
        Case 9
            Entry = "00" & CStr(LCase(MAINws.Cells(Cnt, "C")))
            EArr.Add Entry
    End Select
    MsgBox EArr(Cnt - 1)
Next Cnt

End Sub

Now the code gives me an error when it hits the EArr.Add Entry. The error message is Run-time error '2146232576 (80131700)': Automation error.

Please let me know what i'm doing wrong so i can get this fixed. Thank you.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,213,551
Messages
6,114,266
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top