I 'm defining an array like this and populating it directly without using any loops
But its throwing error "Type mismatch error"
Dim battarray() As Integer
x = Sheets("Names").Range("a4")
ReDim battarray(x) As Integer
battarray() = Array(40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50)
Can some one help me fix this
Sheets("Names").Range("a4")?As Integerand try again.Array(40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50)creates an array of variant, which cant be assigned to an array of integers.Sheets("Names").Range("a4")is an integer which gives dynamic size to the array, based on thatArray(40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50)also changesx = Val(Trim(Sheets("Names").Range("a4").Value))As Integerfrom line 1 and line 3 in the sample code you posted?