"i" in excel macro

eyetrack

New Member
Joined
Jun 20, 2012
Messages
3
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
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,583
Messages
6,120,375
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top