markets = Val(InputBox("Number of markets:", "Settings", 9))
nr = Val(InputBox("Number of observations:", "Settings", 3873)) For j = 1 To markets k=0 For i = 2 To nr + 1 If Cells(i, j) < Cells(nr + 3, j) Then Cells(k + 2, j + markets) = Cells(i, j) k=k+1 End If Next i Cells(nr + 4, j) = WorksheetFunction.Var(Range(Cells(2, j + markets), Cells(k + 2, j + markets))) Next j MsgBox "Ready!", vbInformation, "Settings"