View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
marcus[_3_] marcus[_3_] is offline
external usenet poster
 
Posts: 140
Default Match a cell in a range to a value from another sheet and selectr

Hi Johno

If you set up a worksheet change event in the sheet tab module should
do the trick.
This assumes your Sheet B is called Sheet2 and the cell to change is
in A1 of Sheet1.

You can modify to suit. Good Luck

Marcus



Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastRw As Integer
Dim rngB As Range, rngA As Range

LastRw = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
Set rngA = Range("A1")
Set rngB = Sheets("Sheet2").Range("A2:A" & LastRw)

If Target.Address = "$A$1" Then

For Each cellB In rngB
Found = False
For Each cellA In rngA
If cellB.Value = cellA.Value Then
Found = True
Sheets("Sheet2").Activate
cellB.EntireRow.Select
End If
Next

Next
End If

End Sub