PC Review


Reply
Thread Tools Rate Thread

Basic Search with Wildcharacters

 
 
cubhasker@gmail.com
Guest
Posts: n/a
 
      31st Jul 2007
Below is a Sub I have written. I have huge data in Sheet3 with
different forms of names containing "shell". Whenever I encounter
shell in column A of Sheet3 I should write SHELL in column F

Sub NameBusiness()
Dim srchResult As Integer
Dim temp As String
temp = "search(""*shell*"",sheet3!a2,1)"

For i = 2 To 59998
srchResult = ActiveSheet.Evaluate(temp)

If (srchResult = 1) = True Then
Sheet3.Cells(i, 6) = "Exxon Mobil"
End If

Next i


End Sub

 
Reply With Quote
 
 
 
 
cubhasker@gmail.com
Guest
Posts: n/a
 
      31st Jul 2007
On Jul 31, 4:58 pm, cubhas...@gmail.com wrote:
> Below is a Sub I have written. I have huge data in Sheet3 with
> different forms of names containing "shell". Whenever I encounter
> shell in column A of Sheet3 I should write SHELL in column F
>
> Sub NameBusiness()
> Dim srchResult As Integer
> Dim temp As String
> temp = "search(""*shell*"",sheet3!a2,1)"
>
> For i = 2 To 59998
> srchResult = ActiveSheet.Evaluate(temp)
>
> If (srchResult = 1) = True Then
> Sheet3.Cells(i, 6) = "Exxon Mobil"
> End If
>
> Next i
>
> End Sub


Sorry.. forgot to mention the error I am getting.It throws me a Type
Mismatch error.

Thanks in advance

 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      31st Jul 2007
Instead of Evaluate you would be better off with InStr. That being said Find
will be a much more efficient way to do this...

Sub NameBusiness()
Dim rngToSearch As Range
Dim rngFound As Range
Dim strFirstAddress As String

Set rngToSearch = Sheet3.Columns(6)
Set rngFound = rngToSearch.Find(What:="shell", _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
MatchCase:=False)
If Not rngFound Is Nothing Then
strFirstAddress = rngFound.Address
Do
rngFound.Offset(0, 1).Value = "Shell"
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
End If
End Sub
--
HTH...

Jim Thomlinson


"(E-Mail Removed)" wrote:

> On Jul 31, 4:58 pm, cubhas...@gmail.com wrote:
> > Below is a Sub I have written. I have huge data in Sheet3 with
> > different forms of names containing "shell". Whenever I encounter
> > shell in column A of Sheet3 I should write SHELL in column F
> >
> > Sub NameBusiness()
> > Dim srchResult As Integer
> > Dim temp As String
> > temp = "search(""*shell*"",sheet3!a2,1)"
> >
> > For i = 2 To 59998
> > srchResult = ActiveSheet.Evaluate(temp)
> >
> > If (srchResult = 1) = True Then
> > Sheet3.Cells(i, 6) = "Exxon Mobil"
> > End If
> >
> > Next i
> >
> > End Sub

>
> Sorry.. forgot to mention the error I am getting.It throws me a Type
> Mismatch error.
>
> Thanks in advance
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista Home Basic Search issues Jim Windows Vista General Discussion 4 18th Dec 2007 11:02 PM
How can you conduct the basic search through your documents? =?Utf-8?B?a29uc3VyZWxhd2Zpcm0=?= Microsoft Word Document Management 1 7th Jul 2007 08:45 AM
Useful Visual Basic Search Engine Swicki google@vbinfo.net Microsoft VB .NET 0 5th May 2006 12:48 AM
XP Basic search tool - how to search for specific string. Eg: "Lost In Space" MicroMain Windows XP General 3 8th Mar 2006 04:21 AM
Basic Search Shawn Microsoft Excel Misc 2 20th May 2004 03:49 AM


Features
 

Advertising
 

Newsgroups
 


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