View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default Multiple Offsets

You are only allowed one Worksheet_Change procedure per sheet. However, you
can organize the code to react to multiple conditions, as shown below. Give
it a try and post back if there is a problem.



Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Target.Row = 11 Then
If Len(Target) = 11 Then
ActiveCell.Offset(-10, 2).Select
End If
ElseIf Target.Row = 23 Then
If Len(Target) = 11 Then
ActiveCell.Offset(-10, 2).Select
End If
ElseIf Target.Row = 35 Then
If Len(Target) = 11 Then
ActiveCell.Offset(-10, 2).Select
End If `
End If
End If
End Sub




"Jon M." wrote in message
...
Hi all,
I have a worksheet with the following code listed below. The idea is that
once a cell in a particular row is populated with an 11 digit claim# it
will
jump to the first cell 2 columns over at the top of the particular table
of
claim#'s. I hope that makes sense. Anyways the first Function works
fine,
when I put an 11 digit claim# in row 11 and press enter the correct cell
is
selected at the top of the next column I want to enter in.

However when I try to do the same in Rows 23, 35, and 47 nothing happens.
My code is the same for these functions so I can't figure out why the
other
rows won't function the same. As always any help is always appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Target.Row = 11 Then
If Len(Target) = 11 Then
ActiveCell.Offset(-10, 2).Select
Else
Exit Sub
End If
End If
End Sub

Private Sub Worksheet_Change_2(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Target.Row = 23 Then
If Len(Target) = 11 Then
ActiveCell.Offset(-10, 2).Select
Else
Exit Sub
End If
End If
End Sub

Private Sub Worksheet_Change_3(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Target.Row = 35 Then
If Len(Target) = 11 Then
ActiveCell.Offset(-10, 2).Select
Else
Exit Sub
End If
End If
End Sub

Private Sub Worksheet_Change_4(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Target.Row = 47 Then
If Len(Target) = 11 Then
ActiveCell.Offset(-10, 2).Select
Else
Exit Sub
End If
End If
End Sub
--
Jon M.