H
Howard
Hi Experts,
Why do I know I'm going to be embarrassed by the answer to my query...?
Code takes me to the first empty cell to the right of the E column data.
I don't want to go past column 16 (col. P)
In a test row, i = 18 so there is an if statement to only go to 16 IF i > 15.
However it takes me to column U which is 21.
Works just fine on other rows less than 16 but if i = 16 it goes to 21 also.
Option Explicit
Sub GoRT()
Dim i As Integer
If Not Intersect(ActiveCell, Range("E6:E20")) Is Nothing Then
i = ActiveCell.End(xlToRight).Column
' Msgbox to test i returns 18 on a test row
MsgBox i
' i is > 16 so why does this if statement
' take me to column U which is 21
If i > 16 Then
ActiveCell.Offset(0, 16).Select
Exit Sub
End If
ActiveCell.Offset(0, i - 4).Select
End If
End Sub
Thanks,
Howard
Why do I know I'm going to be embarrassed by the answer to my query...?
Code takes me to the first empty cell to the right of the E column data.
I don't want to go past column 16 (col. P)
In a test row, i = 18 so there is an if statement to only go to 16 IF i > 15.
However it takes me to column U which is 21.
Works just fine on other rows less than 16 but if i = 16 it goes to 21 also.
Option Explicit
Sub GoRT()
Dim i As Integer
If Not Intersect(ActiveCell, Range("E6:E20")) Is Nothing Then
i = ActiveCell.End(xlToRight).Column
' Msgbox to test i returns 18 on a test row
MsgBox i
' i is > 16 so why does this if statement
' take me to column U which is 21
If i > 16 Then
ActiveCell.Offset(0, 16).Select
Exit Sub
End If
ActiveCell.Offset(0, i - 4).Select
End If
End Sub
Thanks,
Howard