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

You said select S, then in the next post you say something about J. The
below selects S. Change to J if that is what you want.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rng As Range, cell as Range, bFound as Boolean
If Target.Count 1 Then Exit Sub
If Target.Address = "$G$2" Then
Cells.Interior.ColorIndex = xlNone
Set rng = Range(Cells(2, 18, Cells(Rows.Count, 18).End(xlUp))
bFound = False
For Each cell In rng
If cell.Value <= Target And cell.Offset(0, 1).Value = Target.Value Then
if not bFound then
cells(cell.row,"S").Select
bFound = True
End If
cell.EntireRow.Interior.ColorIndex = 6
End If
Next
End If
End Sub

--
Regards,
Tom Ogilvy


"Priyanga Fernando" wrote in message
...
Sorry I forgot to mention.
There can be occurrences in this nature too,

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

2 BOX 1 004569 004600

3 BOX2 102000 103000

4 BOX3 102100 102500

5 BOX4 102200 102300



In this situation if you input 102250 to search, three rows have to be
highlighted. Row 3, 4, and 5.
And the selected cell should be at the first occurrence on the row J

After I saw your solution Mr. Tom Ogilvy , only it strikes me about
these new problems.

Sorry for the trouble.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!