Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LastRowText As Long
Dim intRow As Long
Dim strCol As String
Dim strTemp() As String
Dim i As Long
'
'just for safety
If strPrevCell = "" Then
strPrevCell = ActiveCell.Address
Exit Sub
End If
'
' :: add below linest with all the cells you need (e.g. "$C$10", "$D$12", etc)
'
If strPrevCell = "$C$3" Or _
strPrevCell = "$C$4" Or _
strPrevCell = "$C$5" Then
strTemp = Split(strPrevCell, "$")
intRow = CLng(strTemp(2))
strCol = strTemp(1)
'
' :: find the last row in column A
'
LastRowText = Sheets(1).Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
'
' :: loop through the values in the column A
'
For i = 1 To LastRowText
'
'if value in column A is the same with value in our Cell then put in our Cell the value in column B
If UCase(Sheets(1).Cells(i, "A")) = UCase(Cells(intRow, strCol)) Then
Cells(intRow, strCol) = Sheets(1).Cells(i, "B")
Exit For
End If
Next
End If
strPrevCell = ActiveCell.Address
End Sub
|