Hi Troy,
Thanks for all your help.....in the end here is what my code looks like. Definitely, not as elegant as your original solution, but outcome will be the same.
Thanks once again...your code really gave me some inspiration !
Keith
********************** CODE *************************
Dim cellOldValue As Variant
Dim cellNewValue As Variant
Dim cellOldRange As String
********************** CODE *************************
Private Sub Worksheet_Change(ByVal Target As Range)
'This procedure will check whether the user made a change in specific cell
Dim interSectRange As Range
'set the range
Set interSectRange = Range("B16:B1430")
Application.EnableEvents = False
'Check whether active cell is within a specified range, if not then do nothing
If Intersect(Target, interSectRange) Is Nothing Then
' code to handle that the active cell is not within the right range
MsgBox "Active Cell not in Range!"
Application.EnableEvents = True
Exit Sub
Else
' code to handle when the active cell is within the right range
MsgBox "Active Cell In Range!"
Application.EnableEvents = True
'Exit Sub
End If
'Do nothing if more than one cell is changed or content deleted
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
'Ensure target cell value is a number
If IsNumeric(Target) Then
MsgBox "Value entered is a number!"
Application.EnableEvents = True
'Exit Sub
Else
MsgBox "value entered is not a number, please verify!"
Application.EnableEvents = True
Exit Sub
End If
'Check whether target cell address is valid before calling swapCells subroutine
If (Target.Row - Range("B16").Row) Mod 14 = 0 Then
MsgBox "The cell you have selected is allowed!"
cellNewValue = Target.Value
MsgBox " old value is " & cellOldValue
MsgBox " old cell address is " & cellOldRange
MsgBox " new value is " & cellNewValue
Application.EnableEvents = True
Call swapCellValue
'Exit Sub
Else
MsgBox "the cell you have selected is not allowed!"
Application.EnableEvents = True
Exit Sub
End If
Application.EnableEvents = True
End Sub
********************** CODE *************************
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'this code will store the old cell value before change is made by user
cellOldValue = ActiveCell.Value
cellOldRange = ActiveCell.Address
End Sub
********************** CODE *************************
Private Sub swapCellValue()
MsgBox " subroutine swapCellValue was called "
Dim c As Range
Dim kpiRange As Range
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Main")
Set kpiRange = ws.Range("B16:B1430")
For Each c In kpiRange
If (cellOldRange <> c.Address) And (cellNewValue = c.Value) Then
MsgBox " match found at " & c.Address & " with rank : " & c.Value
Exit Sub
End If
Next c
cellOldValue = vbNullString
End Sub
*********************** END OF CODE ********************