Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Find problem

Column 1 contains the numeric ID of about 2,000 rows.

A variable iID, or should it be sID, records the ID before sorting by
another column.

I then need to find which particular row contains the ID, select it and
scroll to it.



The problem:

Let us say the ID is 27

After sorting 27 is below 275 so 'Find' finds 275 first!



How can I find the row which contains the ID 27 and not a larger number
containing the original digits?



Francis Hookham


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Find problem

i had to hard code some of it, but give this a try. there is not enough
information about your data.

Sub test()
Dim ws As Worksheet
Dim rngfound As Range
Dim rng As Range
Dim sID As String ' not sure what you're looking for
Set ws = Worksheets("Sheet1") ' change this
Set rng = ws.Range("A1:A30") ' change this
sID = 27 ' hard coded
With rng
Set rngfound = .Find(sID, lookat:=xlWhole, LookIn:=xlValues)
End With
If Not rngfound Is Nothing Then
Application.Goto ws.Range("A" & rngfound.Row), scroll:=True
End If

End Sub

--


Gary


"Francis Hookham" wrote in message
...
Column 1 contains the numeric ID of about 2,000 rows.

A variable iID, or should it be sID, records the ID before sorting by another
column.

I then need to find which particular row contains the ID, select it and scroll
to it.



The problem:

Let us say the ID is 27

After sorting 27 is below 275 so 'Find' finds 275 first!



How can I find the row which contains the ID 27 and not a larger number
containing the original digits?



Francis Hookham




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find problem

If I understand your question correctly, click the Options button on the
Find dialog and select the "Match entire cell contents" option (along with
the Search "By Columns" option I would guess).

Rick


"Francis Hookham" wrote in message
...
Column 1 contains the numeric ID of about 2,000 rows.

A variable iID, or should it be sID, records the ID before sorting by
another column.

I then need to find which particular row contains the ID, select it and
scroll to it.



The problem:

Let us say the ID is 27

After sorting 27 is below 275 so 'Find' finds 275 first!



How can I find the row which contains the ID 27 and not a larger number
containing the original digits?



Francis Hookham



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Find problem

Even without VBA:

Edit Find
and make sure entire cell contents is checked.

With VBA
--
Gary''s Student - gsnu200789


"Francis Hookham" wrote:

Column 1 contains the numeric ID of about 2,000 rows.

A variable iID, or should it be sID, records the ID before sorting by
another column.

I then need to find which particular row contains the ID, select it and
scroll to it.



The problem:

Let us say the ID is 27

After sorting 27 is below 275 so 'Find' finds 275 first!



How can I find the row which contains the ID 27 and not a larger number
containing the original digits?



Francis Hookham



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Find problem

Thanks Gary, Gary's Student and Rick

It is the
LookIn:=xlValues, LookAt :=xlWhole,
that does the trick.

I should have looked in the Options - I always should but don't always
remember!

As always you guys do a fantastic job.

Francis


Sub FindSameNames()
Application.ScreenUpdating = False
iRefNum = Cells(ActiveCell.Row, 1)
SortByID 'macro to sort col 1
SortBySubject 'macro to sort col 5
Columns("A:A").Select
Selection.Find(What:=iRefNum, After:=ActiveCell, LookIn:=xlValues,
LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase _
:=False, SearchFormat:=False).Activate
iRowNum = ActiveCell.Row
ActiveWindow.ScrollRow = iRowNum
Cells(iRowNum, 5).Select
End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Find problem

Apologies - I thought I had sent this but cannot find it:

Thanks Gary, Gary's Student and Rick

It is the
LookIn:=xlValues, LookAt :=xlWhole,
that does the trick.

I should have looked in the Options - I always should but don't always
remember!

As always you guys do a fantastic job.

Francis


Sub FindSameNames()
Application.ScreenUpdating = False
iRefNum = Cells(ActiveCell.Row, 1)
SortByID 'macro to sort col 1
SortBySubject 'macro to sort col 5
Columns("A:A").Select
Selection.Find(What:=iRefNum, After:=ActiveCell, LookIn:=xlValues,
LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase _
:=False, SearchFormat:=False).Activate
iRowNum = ActiveCell.Row
ActiveWindow.ScrollRow = iRowNum
Cells(iRowNum, 5).Select
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Err 13 Cant find problem Arne Hegefors Excel Programming 1 November 17th 07 06:23 AM
Find Problem John Excel Programming 2 September 28th 06 09:58 AM
Find and Find Next problem Richard Hocking Excel Programming 2 September 13th 06 03:51 PM
Find Next problem Terry K Excel Programming 8 November 21st 05 05:17 PM
problem with FIND cjsmith22 Excel Worksheet Functions 3 November 17th 05 11:03 PM


All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"