View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Macro to search number with in a series.

Assume you want to react with a value is entered in G2

right click on the sheet module and select view code. Paste in code like
this:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rng As Range
If Target.Count 1 Then Exit Sub
If Target.Address = "$G$2" Then
Cells.Interior.ColorIndex = xlNone
Set rng = Range(Cells(2, 2), Cells(Rows.Count, 2).End(xlUp))
For Each cell In rng
If cell.Value <= Target And cell.Offset(0, 1).Value = Target.Value Then
cell.EntireRow.Interior.ColorIndex = 6
Exit Sub
End If
Next
End If
End Sub

Assumes you aren't using colored cells on the sheet, except for this
highlight.

--
Regards,
Tom Ogilvy


"Fernando" wrote in message
om...
Dear frineds,

I have an Excel table like below,


A B C
1 Box Number Seal num. from Seal num. to

2 BOX 1 004569 004600

3 BOX2 020034 020106

4 BOX3 000237 000320

5 BOX4 001003 001130



I want to write a macro to search a Seal Number with in the series. For

example,
When I input 020100, it should highlight the row 3. as well when I input

000300
It should highlight row 4.

Could anyone give me a bright idea as how to do this?
Thank you in advance.