Hello,

My problem is still kind of confusing because I am still trying to figure out exactly what it is I want to do.

I have multiple columns of data. I would like to plot each column against time. However, these columns in the future may be made longer, and I would like to "do math" in some of these columns. I don't want "the math" to update the columns.

Therefore, I had the idea of making arrays. I could find the number of rows in the columns, pass that number as the number of elements in the array to a function (which does the math I want) and return that array.

Anyhow, I am getting errors! A subscript out of range error.

   

Private Sub getPlots_Click()

Dim arrayIndex As Integer
Dim numberOfRows As Range
Dim i As Integer
Dim newArray() As Double

i = 5 'column number

While Cells(8, i) <> ""
    
    Set numberOfRows = Range(Cells(8, i), Cells(Rows.Count, i).End(xlUp))
    arrayIndex = numberOfRows.Rows.Count
       
        
    newArray(arrayIndex) = makeArray(arrayIndex, i) 'update array
    
    i = i + 1
Wend


End Sub

Function makeArray(arrayIndex As Integer, columnNumber As Integer)

    Dim normalizedArray() As Double
    Dim i As Integer
    
    i = 0
    
    For m = 9 To arrayIndex
    
        normalizedArray(i) = Cells(m, columnNumber).Value / Cells(m, columnNumber - 1).Value
    
        i = i + 1
        
    Next m
    

End Function