Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default "Search" Macro problem Help!!!!

Hi everyone,

I have this macro that searches for the value in column A in every
sheets and return the name of the sheet if the value is found in
column C

Major problem I am having with this macro is that when it searches it
doesn't go for the exact value but everything that includes the search
value.
i.e. if I run a search for "123" and if there is a entry such as
"ABC123" in sheet2 It will count that as search result.

How do I alther my code in order to search for exact values?

Thank you for your help in advance.

regards,


James



Sub SearchAllSheets()

For i = 6 To 116
If Range("A" & i) < "" Then
Range("C" & i).ClearContents
For Each sh In Worksheets
If sh.Name < ActiveSheet.Name Then
Set searchresult = sh.Cells.Find(Range("A" & i), _
lookat:=xlPart)
If Not searchresult Is Nothing Then
Range("C" & i) = Range("C" & i) & " " & " | " & sh.Name
End If
End If
Next
End If
Next


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default "Search" Macro problem Help!!!!

Try changing lookat:=xlPart to LookAt:= xlWhole
--
Regards,

OssieMac


"James8309" wrote:

Hi everyone,

I have this macro that searches for the value in column A in every
sheets and return the name of the sheet if the value is found in
column C

Major problem I am having with this macro is that when it searches it
doesn't go for the exact value but everything that includes the search
value.
i.e. if I run a search for "123" and if there is a entry such as
"ABC123" in sheet2 It will count that as search result.

How do I alther my code in order to search for exact values?

Thank you for your help in advance.

regards,


James



Sub SearchAllSheets()

For i = 6 To 116
If Range("A" & i) < "" Then
Range("C" & i).ClearContents
For Each sh In Worksheets
If sh.Name < ActiveSheet.Name Then
Set searchresult = sh.Cells.Find(Range("A" & i), _
lookat:=xlPart)
If Not searchresult Is Nothing Then
Range("C" & i) = Range("C" & i) & " " & " | " & sh.Name
End If
End If
Next
End If
Next


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
search for text "beginning with" "containing" wildcards David H Excel Worksheet Functions 1 January 13th 10 01:24 PM
=IF(ISNUMBER(SEARCH("ELB",B2)),"Pipe") add more like "ELB" "FLG" MAHMOUD Excel Worksheet Functions 5 September 6th 09 06:04 PM
=IF(ISERROR(SEARCH("insurance",A125,1)),"","*") cynichromantique Excel Worksheet Functions 9 September 25th 08 09:49 PM
Problem with "Search box" in Help window Maurene Garza Excel Discussion (Misc queries) 0 November 4th 05 06:00 PM


All times are GMT +1. The time now is 10:22 AM.

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

About Us

"It's about Microsoft Excel"