VBA How to declare an array with elements with different datatype
excel, vba
Solution
You'll want to create an array of type Variant. An array of type Variant can store any data type in any of its elements.
Dim astrItems(0 To 9) As String
Dim varItems As Variant
varItems = astrItems
Problem
I have an array that I have created to store error records and it has the following elements: Serial No,File name, error type, error cell, error cell value As of now I have declared my array like this and then I populate the values later on. ``` Dim errorArray() As String ``` But ideally, I want Serial Number to be a proper integer, but it is getting converted into string. I don't know how to declare this correctly so that I can have Long datatype for the first element and string for the next 3 and variant for the last one.