Combining If Not Is Nothing
Posted by sid on October 16, 2001 9:48 AM
Combining If Not Is Nothing
I am trying to use the code below to check what column a value is in
It partially works but, gets confused over close values e.g. K1 is in col1, but shows as col3 after K100 is checked (which is in col3)
This is what I have cobbled together from the board, can anyone tidy it please. Or is there a better way to get this information.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Columns(9)) Is Nothing Then
Dim rng1 As Range
Set rng1 = Worksheets("INDEX").Columns(43).Find(Target.Value)
If Not rng1 Is Nothing Then Target.Offset(0, 8).Value = 1
End If
If Not Intersect(Target, Columns(9)) Is Nothing Then
Dim rng2 As Range
Set rng2 = Worksheets("INDEX").Columns(44).Find(Target.Value)
If Not rng2 Is Nothing Then Target.Offset(0, 8).Value = 2
End If
If Not Intersect(Target, Columns(9)) Is Nothing Then
Dim rng3 As Range
Set rng3 = Worksheets("INDEX").Columns(45).Find(Target.Value)
If Not rng3 Is Nothing Then Target.Offset(0, 8).Value = 3
End If