View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Auric__ Auric__ is offline
external usenet poster
 
Posts: 538
Default If .Column 7 And .Row 25 then go to B8

Howard wrote:

Hi experts, this second line of code is making me feel foolish.
The first line does its thing where data is entered and upon enter moves
to the right until column 8 then correctly act like a carriage
return back to column B and next row down.

Once I get past G25 I want to return to B8... what have I got screwed up in
the second line?

If ActiveCell.Column 7 Then ActiveCell.Offset(1, -6).Select
If ActiveCell.Column 7 And ActiveCell.Row 25 Then _
ActiveCell.Offset(-18, -6).Select


Rather than moving around via offsets, just go straight to the cell you want:

If ActiveCell.Column 7 Then
If ActiveCell.Row 24 Then
Range("B8").Select
Else
Cells(ActiveCell.Row + 1, 2).Select
End If
Else
Cells(ActiveCell.Row, 8).Select
End If

Doing it this way is also somewhat clearer than your method, IMHO.

--
Noisy, opinionated, often wrong... but rarely uncertain.