PC Review


Reply
Thread Tools Rate Thread

Create custom wildcard for searches?

 
 
wal
Guest
Posts: n/a
 
      29th Nov 2008
Excel 2003

I'm using Excel to compile customized lists of words for spelling
exercises. I have several sheets with lists/tables of words. I want
to extract from them words including, for example, the combination "a"
+ consonant + consonant (e.g., the word "back").

Thus far, I've been managing with simple wildcard searches that find
the words on a given sheet and copy-paste them in a column on another
sheet. E.g., search for the string "a??". However, this gives
incorrect strings, like "bake", that I have to delete manually.

The basic code is:

Dim tXt As String
tXt = InputBox("Enter the string you want to find.", " ", , 0, 0)

With Worksheets(sHt).Range("a1:fb66")
Dim xx, firstAddress
Set xx = .Find(What:=tXt, [etc.])
If Not xx Is Nothing Then
firstAddress = xx.Address
Do
xx.Activate
Selection.Copy
Sheets("TempLists").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ActiveCell.Offset(1, 0).Activate
Sheets(sHt).Select
Set xx = .FindNext(xx)
Loop While Not xx Is Nothing And xx.Address <> firstAddress
End If
End With

To eliminate words I don't want, I tried creating a custom wildcard
for the consonants, as follows:

Dim cc(1 To 19) As String
cc(1) = "b"
cc(2) = "c"
...
cc(19) = "z"

Dim tXt As String

tXt = "a" & cc & cc [followed by the With...End With code, above]

However, the "type mismatch" error occurs at the line immediately
above, with the & character highlighted. Evidently, even though "a"
is a string and cc is a string, they can't be combined?

Any ideas for doing what I'm trying to do, even if they're totally
different from the code I've tried so far?

Thanks.
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      29th Nov 2008
There is a reference you can include for Regular expressions. Once included:

http://msdn.microsoft.com/en-us/library/1400241x(VS.85).aspx
--
Gary''s Student - gsnu200816


"wal" wrote:

> Excel 2003
>
> I'm using Excel to compile customized lists of words for spelling
> exercises. I have several sheets with lists/tables of words. I want
> to extract from them words including, for example, the combination "a"
> + consonant + consonant (e.g., the word "back").
>
> Thus far, I've been managing with simple wildcard searches that find
> the words on a given sheet and copy-paste them in a column on another
> sheet. E.g., search for the string "a??". However, this gives
> incorrect strings, like "bake", that I have to delete manually.
>
> The basic code is:
>
> Dim tXt As String
> tXt = InputBox("Enter the string you want to find.", " ", , 0, 0)
>
> With Worksheets(sHt).Range("a1:fb66")
> Dim xx, firstAddress
> Set xx = .Find(What:=tXt, [etc.])
> If Not xx Is Nothing Then
> firstAddress = xx.Address
> Do
> xx.Activate
> Selection.Copy
> Sheets("TempLists").Select
> Selection.PasteSpecial Paste:=xlPasteValues
> Application.CutCopyMode = False
> ActiveCell.Offset(1, 0).Activate
> Sheets(sHt).Select
> Set xx = .FindNext(xx)
> Loop While Not xx Is Nothing And xx.Address <> firstAddress
> End If
> End With
>
> To eliminate words I don't want, I tried creating a custom wildcard
> for the consonants, as follows:
>
> Dim cc(1 To 19) As String
> cc(1) = "b"
> cc(2) = "c"
> ...
> cc(19) = "z"
>
> Dim tXt As String
>
> tXt = "a" & cc & cc [followed by the With...End With code, above]
>
> However, the "type mismatch" error occurs at the line immediately
> above, with the & character highlighted. Evidently, even though "a"
> is a string and cc is a string, they can't be combined?
>
> Any ideas for doing what I'm trying to do, even if they're totally
> different from the code I've tried so far?
>
> Thanks.
>

 
Reply With Quote
 
wal
Guest
Posts: n/a
 
      30th Nov 2008
Thanks very much. Although the actual explanations on the pages you
referred to are about as transparent as the Excel VBA Help files, I
was ultimately able to use them to cobble together some Regular
Expressions code that serves my purposes.


On Nov 29, 11:28*am, Gary''s Student
<GarysStud...@discussions.microsoft.com> wrote:
> There is a reference you can include for Regular expressions. *Once included:
>
> http://msdn.microsoft.com/en-us/library/1400241x(VS.85).aspx
> --
> Gary''s Student - gsnu200816
>
>
>
> "wal" wrote:
> > Excel 2003

>
> > I'm using Excel to compile customized lists of words for spelling
> > exercises. *I have several sheets with lists/tables of words. *I want
> > to extract from them words including, for example, the combination "a"
> > + consonant + consonant (e.g., the word "back").

>
> > Thus far, I've been managing with simplewildcardsearches that find
> > the words on a given sheet and copy-paste them in a column on another
> > sheet. *E.g., search for the string "a??". *However, this gives
> > incorrect strings, like "bake", that I have to delete manually.

>
> > The basic code is:

>
> > Dim tXt As String
> > tXt = InputBox("Enter the string you want to find.", " ", , 0, 0)

>
> > With Worksheets(sHt).Range("a1:fb66")
> > * * Dim xx, firstAddress
> > * * Set xx = .Find(What:=tXt, [etc.])
> > * * If Not xx Is Nothing Then
> > * * * * firstAddress = xx.Address
> > * * * * Do
> > * * * * * * xx.Activate
> > * * * * * * Selection.Copy
> > * * * * * * Sheets("TempLists").Select
> > * * * * * * Selection.PasteSpecial Paste:=xlPasteValues
> > * * * * * * Application.CutCopyMode = False
> > * * * * * * ActiveCell.Offset(1, 0).Activate
> > * * * * * * Sheets(sHt).Select
> > * * * * * * Set xx = .FindNext(xx)
> > * * * * Loop While Not xx Is Nothing And xx.Address <> firstAddress
> > * * End If
> > End With

>
> > To eliminate words I don't want, I tried creating a customwildcard
> > for the consonants, as follows:

>
> > Dim cc(1 To 19) As String
> > * * cc(1) = "b"
> > * * cc(2) = "c"
> > * * ...
> > * * cc(19) = "z"

>
> > Dim tXt As String

>
> > tXt = "a" & cc & cc *[followed by the With...End With code, above]

>
> > However, the "type mismatch" error occurs at the line immediately
> > above, with the & character highlighted. *Evidently, even though "a"
> > is a string and cc is a string, they can't be combined?

>
> > Any ideas for doing what I'm trying to do, even if they're totally
> > different from the code I've tried so far?

>
> > Thanks.- Hide quoted text -

>
> - Show quoted text -


 
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
Wildcard Searches in IF Formulas Jay Microsoft Excel Worksheet Functions 3 22nd Jan 2009 01:51 PM
wildcard searches 2Blessed4Stress Microsoft Access Queries 2 24th Jul 2008 07:24 PM
Wildcard Searches across Worksheets avilliers@gmail.com Microsoft Excel Worksheet Functions 1 25th Jan 2008 11:34 PM
Wildcard searches =?Utf-8?B?ZnJhY3RhbHN1YXI=?= Windows Vista File Management 5 23rd Aug 2006 01:58 PM
wildcard searches fred Microsoft C# .NET 2 13th Oct 2003 01:22 PM


Features
 

Advertising
 

Newsgroups
 


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