I would like to collect data from several cells on multiple sheets into an array but this is presenting a problem. I can fill an array with data from cells on the active sheet using the code below:
However, when I attempt to collect data from the current sheet and then another sheet, the d(0) and d(1) expressions run but I get an error at the d(2) expression (Runtime error '9': subscript out of range).Sub store_data() Dim d(4) As String d(0) = Range("E7").Value d(1) = Range("E8").Value d(3) = Range("E9").Value d(4) = Range("E10").Value End Sub
Any help would be appreciated.Sub store_data() Dim d(4) As String d(0) = Range("E7").Value d(1) = Range("E8").Value d(2) = Sheets("sheet6").Range("E9").Value d(3) = Sheets("sheet6").Range("E10").Value End Sub