I use excel macros to process eyetracking data. I have a macro (that someone else gave me) that takes data from a “Raw” data sheet and summarises it in a “Results” sheet. It uses the time stamp (timestop-timestart) to calculate the length of each fixation # (fix- time), and associates the AOI (area of interest), TrialID, TrialPhase, and LagCond by taking the value of the relevant column from the END of the fixation. I want to add a new parameter to be associated with each fixation # but I want it to take the value from the START of the fixation, rather than the END. I know that it has something to do with the “i”, but can’t work it out.
Here is the macro I am currently using...
Sub TOBII2()
Set rs = Sheets("Results")
rs.Range("A1:H500").ClearContents
With rs
.Range("A1") = "Fix-#"
.Range("B1") = "Fix-Time"
.Range("C1") = "AOI"
.Range("D1") = "TrialID"
.Range("E1") = "TrialPhase"
.Range("F1") = "LagCond"
End With
i = 2 'Start in row 2
fixation = 1
timestart = Cells(i, 1)
While Not IsEmpty(Cells(i, 1))
Cells(i, 8) = fixation
If Cells(i, 7) > 2500 Or Cells(i, 17) <> Cells(i + 1, 17) Then
fixation = fixation + 1 'incriment fixation
Row = rs.Range("A65536").End(xlUp).Row + 1
timestop = Cells(i, 1).Value
rs.Cells(Row, 1) = Cells(i, 8).Value
rs.Cells(Row, 2) = timestop - timestart
rs.Cells(Row, 3) = Cells(i, 15).Value
rs.Cells(Row, 4) = Cells(i, 11).Value
rs.Cells(Row, 5) = Cells(i, 17).Value
rs.Cells(Row, 6) = Cells(i, 12).Value
timestart = Cells(i + 1, 1).Value
End If
i = i + 1
Wend
End Sub
I want to add .Range("G1") = "TimeBin"
rs.Cells(Row, 7) = Cells(i, 18).Value
But rather than taking the End value from Column 18, i want it to take the Time Start value.
Hope that makes sense. Let me know if an example of the data would help
thanks!
Jenny
Here is the macro I am currently using...
Sub TOBII2()
Set rs = Sheets("Results")
rs.Range("A1:H500").ClearContents
With rs
.Range("A1") = "Fix-#"
.Range("B1") = "Fix-Time"
.Range("C1") = "AOI"
.Range("D1") = "TrialID"
.Range("E1") = "TrialPhase"
.Range("F1") = "LagCond"
End With
i = 2 'Start in row 2
fixation = 1
timestart = Cells(i, 1)
While Not IsEmpty(Cells(i, 1))
Cells(i, 8) = fixation
If Cells(i, 7) > 2500 Or Cells(i, 17) <> Cells(i + 1, 17) Then
fixation = fixation + 1 'incriment fixation
Row = rs.Range("A65536").End(xlUp).Row + 1
timestop = Cells(i, 1).Value
rs.Cells(Row, 1) = Cells(i, 8).Value
rs.Cells(Row, 2) = timestop - timestart
rs.Cells(Row, 3) = Cells(i, 15).Value
rs.Cells(Row, 4) = Cells(i, 11).Value
rs.Cells(Row, 5) = Cells(i, 17).Value
rs.Cells(Row, 6) = Cells(i, 12).Value
timestart = Cells(i + 1, 1).Value
End If
i = i + 1
Wend
End Sub
I want to add .Range("G1") = "TimeBin"
rs.Cells(Row, 7) = Cells(i, 18).Value
But rather than taking the End value from Column 18, i want it to take the Time Start value.
Hope that makes sense. Let me know if an example of the data would help
thanks!
Jenny