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.
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.
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.