I have data that is output into 4 channels, one channel a second (channel 1 = 1st second, channel 2 = 2nd second, etc). So there are 4 columns for time and 4 for the associated data, which outputs into excel format.
I have created a simple for loop to collate the 4 columns of data into one, for each parameter. There are 124 parameters, and 5000 - 15000 data points long.
My current for loop is taking about 16 seconds per loop, which means it will take about 33 minutes per run to collate the data. I am no expert with coding or VBA by any stretch, so please forgive the bad format, etc.. just wondering if anyone here may have suggestions for improving the speed of this for loop. The slowest part seems to be the 'i' for loop, removing the 'k' for loop it is still 16 seconds or more.
The code is below:
Sub Create_CombinedData()
'
' Create_CombinedData Macro
'
Sheets("Sheet2").Select
graphrange = Application.WorksheetFunction.CountA(ActiveSheet.Columns(1))
j = 0
m = 497
n = 498
o = 0
For k = 1 To 124
For i = 2 To graphrange
Cells(i + j, m).Value = Cells(2 * i - 2, o + 249).Value
Cells(i + j, n).Value = Cells(2 * i - 2, o + 250).Value
Cells(1 + i + j, m).Value = Cells(2 * i - 2, o + 373).Value
Cells(1 + i + j, n).Value = Cells(2 * i - 2, o + 374).Value
Cells(2 + i + j, m).Value = Cells(2 * i - 2, o + 1).Value
Cells(2 + i + j, n).Value = Cells(2 * i - 2, o + 2).Value
Cells(3 + i + j, m).Value = Cells(2 * i - 2, o + 125).Value
Cells(3 + i + j, n).Value = Cells(2 * i - 2, o + 126).Value
j = j + 3
Next i
m = m + 2
n = n + 2
o = o + 2
l = 2
j = 0
Next k
End Sub
application.screenupdating=false, finish it withapplication.screenupdating=trueand see if that makes it fast enough for youlis being used beyondl = 2.kalso seems to be useless, besides iterating through the 4 variables (which one of which could just bek).