Perplexing IF statement
Howard,
This code takes you to column 21 because of the line:
ActiveCell.Offset(0, 16).Select
That line will start from the active cell (which is in column E) and go over 16 columns. Since column E is the 5th column, 16 columns over from the active cell is column 21.
To fix, simply change the column offset to:
ActiveCell.Offset(0, 12).Select
Or you could remove the IF statement altogether and rewrite as:
Sub GoRT()
Dim i As Integer
If Not Intersect(ActiveCell, Range("E6:E20")) Is Nothing Then
i = ActiveCell.End(xlToRight).Column
i = WorksheetFunction.Min(i, 16) - 4
MsgBox i
ActiveCell.Offset(0, i).Select
End If
End Sub
|