Hi barbara,
From this little piece of code I understand that you create a
validation list "on the fly" and always in column intCol.
For the next piece of code to work you need to make intCol public, so
declare it above your code as
public intCol as integer
and remove the old dim intCol
insert the next piece of code in your worksheet module in the way I
described in the former post:
right-click the tab of the sheet and select "View code", then copy and
paste the next piece of code into the worksheet module:
'----------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim index As Integer
Application.EnableEvents = False
' --- Check if it is the cell with the list validation that has been
changed
If Target.Column = intCol Then
index = 0 ' if not found n will be 0
On Error Resume Next ' to avoid error message when not
found
index = WorksheetFunction.Match(Target, Range("strRange"), 0)
' lookup in the list
If index Then ' If found in list then do something
Target.Value = Range("strRange")(index) ' Get
corresponding list item
End If
End If
Application.EnableEvents = True
End Sub
'---------------------------------------------------------------------------------------
I tested it and it appears that it only works if strRange is on the
same sheet as the cell with the list. If you need it to be on another
sheet, we'll need to find another solution.
If this still doen't help, send me the sheet and I will fix it.
Greetz,
Lex