View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
rudawg rudawg is offline
external usenet poster
 
Posts: 9
Default Is If-Then Else limited to seven Elseif's??

Thanks Don,

I have 10 conditions. The code is long and probably inefficient. But here
goes.....

Private Sub Worksheet_SelectionChange2(ByVal Target As Range)

Dim Left_Value, Right_Value As Variant

Set Left_Value = Nothing
Set Right_Value = Nothing

If Target.Column = 13 Then '<----M
If Target.Row 8 Then
If Target.Row < 70 Then
Left_Value = ActiveCell.Offset([-1], [-1]).Text
Right_Value = ActiveCell.Offset([1], [-1]).Text
[b2] = Left_Value
[af2] = Right_Value
End If
End If

ElseIf Target.Column = 14 Then '<----N
If Target.Row 10 Then
If Target.Row < 68 Then
Left_Value = ActiveCell.Offset([-2], [-1]).Text
Right_Value = ActiveCell.Offset([2], [-1]).Text
[b2] = Left_Value
[af2] = Right_Value
End If
End If

ElseIf Target.Column = 15 Then '<----O
If Target.Row 14 Then
If Target.Row < 64 Then
Left_Value = ActiveCell.Offset([-4], [-1]).Text
Right_Value = ActiveCell.Offset([4], [-1]).Text
[b2] = Left_Value
[af2] = Right_Value
End If
End If

ElseIf Target.Column = 16 Then '<----P
If Target.Row 22 Then
If Target.Row < 56 Then
Left_Value = ActiveCell.Offset([-8],
[-1]).Text
Right_Value = ActiveCell.Offset([8],
[-1]).Text
[b2] = Left_Value
[af2] = Right_Value
End If
End If

ElseIf Target.Column = 18 Then '<----R
If Target.Row 29 Then
If Target.Row < 31 Then
Left_Value = ActiveCell.Offset([-7],
[-2]).Text
Right_Value =
ActiveCell.Offset([25], [-2]).Text
[b2] = Left_Value
[af2] = Right_Value
End If
End If

ElseIf Target.Column = 20 Then '<----T
If Target.Row 47 Then
If Target.Row < 49 Then
Left_Value =
ActiveCell.Offset([-25], [2]).Text
Right_Value = ActiveCell.Offset([7],
[2]).Text
[b2] = Left_Value
[af2] = Right_Value
End If
End If

ElseIf Target.Column = 22 Then
'<----V
If Target.Row 22 Then
If Target.Row < 56 Then
Left_Value =
ActiveCell.Offset([-8], [2]).Text
Right_Value =
ActiveCell.Offset([8], [2]).Text
[b2] = Left_Value
[af2] = Right_Value
End If
End If

'ElseIf Target.Column = 24
Then '<----X
'If Target.Row 14 Then
'If Target.Row < 64 Then
'Left_Value =
ActiveCell.Offset([-4], [1]).Text
'Right_Value =
ActiveCell.Offset([4], [1]).Text
'[b2] = Left_Value
'[af2] = Right_Value
'End If
'End If

'ElseIf
Target.Column = 25 Then '<----Y
'If Target.Row
10 Then
'If Target.Row <
68 Then
'Left_Value =
ActiveCell.Offset([-2], [1]).Text
'Right_Value =
ActiveCell.Offset([2], [1]).Text
'[b2] = Left_Value
'[af2] =
Right_Value
'End If
'End If

'ElseIf
Target.Column = 26 Then '<----Z
'If
Target.Row 8 Then
'If
Target.Row < 70 Then
'Left_Value
= ActiveCell.Offset([-1], [1]).Text
'Right_Value
= ActiveCell.Offset([1], [1]).Text
'[b2] =
Left_Value
'[af2] =
Right_Value
'End If
'End If


End If
End Sub


"Don Guillett" wrote:

Perhaps it would help to post your code.

--
Don Guillett
SalesAid Software

"rudawg" wrote in message
...
I seem to be running into the same limit as I would with a function of
nested
ifs.