Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 02-18-2016, 06:35 PM
Marrick13 Marrick13 is offline Need to improve speed of Excel macro that searches for whole word matches Windows XP Need to improve speed of Excel macro that searches for whole word matches Office 2010 32bit
Competent Performer
Need to improve speed of Excel macro that searches for whole word matches
 
Join Date: Jun 2006
Posts: 102
Marrick13 will become famous soon enough
Default


I realze the caret mans you want to keep the following letters, as in "keeping" them in a replace situation. I was looking at them to identify whole word matches, so I presume if he code detects a letter or number before or after the search text it finds, it should regard that hit as NOT a whole word match. However, if the hit has punctuation or a special character on either adjacent side, such as a comma, $, !, :, etc., I think it should regard the term as a whole word and extract it. I tried plugging that long pattern above into the code and got syntax errors, and it's too many characters for me to figure out what's wrong with it. But I do know that if I run the code with .Pattern = "[^A-Za-z0-9\ ]", it ignores all hits that have a dash (or hyphen) before or after the search term (without spaces). That's what I'm after - how to get the code to accept hits with adjacent punctuation or special characters as whole word matches. I still don't know how to get there.
Reply With Quote
  #17  
Old 02-18-2016, 08:24 PM
NoSparks NoSparks is offline Need to improve speed of Excel macro that searches for whole word matches Windows 7 64bit Need to improve speed of Excel macro that searches for whole word matches Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Quote:
I tried plugging that long pattern above into the code and got syntax errors
That was the string of characters I put into cell D2 to check that .Pattern = "[^A-Za-z0-9\ ]" was all that was required to remove all those particular characters.
It was.

I can't figure out what you're talking about, nor why.
All the string manipulation, array population and matching to the SearchText happens in memory.
Without using message boxes or debug.print to show the individual array elements, you can't see what's going on.
Where is it you are finding these "hits that have a dash (or hyphen) before or after the search term (without spaces)." that you think are not being treated as whole words?
And what do you mean by extract it? I was of the impression the intent was to copy entire rows.
Reply With Quote
  #18  
Old 02-19-2016, 05:24 AM
NoSparks NoSparks is offline Need to improve speed of Excel macro that searches for whole word matches Windows 7 64bit Need to improve speed of Excel macro that searches for whole word matches Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

After reading and re-reading....

Maybe try adding this UDF.
Then in the main procedure, on the Split line, change RemovePunctuation to removeSpecial

Code:
Function removeSpecial(sInput As String) As String
    Dim sSpecialChars As String
    Dim i As Long
    sSpecialChars = "\/:*?™""®<>|.&@#(_+`©~);-+=^$!,'"     ' list of characters to deal with
    For i = 1 To Len(sSpecialChars)
        sInput = Replace$(sInput, Mid$(sSpecialChars, i, 1), " ")
    Next
    removeSpecial = sInput
End Function
Reply With Quote
  #19  
Old 02-19-2016, 08:38 AM
Marrick13 Marrick13 is offline Need to improve speed of Excel macro that searches for whole word matches Windows XP Need to improve speed of Excel macro that searches for whole word matches Office 2010 32bit
Competent Performer
Need to improve speed of Excel macro that searches for whole word matches
 
Join Date: Jun 2006
Posts: 102
Marrick13 will become famous soon enough
Default

NoSparks, hyou've hit the nail on the head. That new function is what I was looking for. I just ran some tests and it does just what I want it to do.

I know all that stuff happens in memory and it's hard to trace (one reason I asked for help). And I was testing the code changes against my database, which does contain punctuation: one of my searches was for a term, some of which occurrences had a preceding dash and some of which didn't. And by "extract", well, I always called the original macro "Extract_Rows_by_Text" because to me, I am searching for text, then copying it, then extracting it to a new workbook. Not JUST copying it. When one queries a database to produce a report, is that not called an extract? I never heard anyone wanting a report about data ask for a "copy", but for an "extract", yes!

Semantics aside, I greatly appreciate your help and patience with this task. It means a lot!
Reply With Quote
  #20  
Old 02-19-2016, 09:49 AM
NoSparks NoSparks is offline Need to improve speed of Excel macro that searches for whole word matches Windows 7 64bit Need to improve speed of Excel macro that searches for whole word matches Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

I just couldn't get my head around what you were describing.

Don't know if there's many applicable instances in the sample data but had you said do a search for 'can' and seq 26 should show up,
it would have been the perfect illustration to straighten me out on what was happening.

Anyway glad it's sorted out.
Reply With Quote
  #21  
Old 02-19-2016, 09:54 AM
Marrick13 Marrick13 is offline Need to improve speed of Excel macro that searches for whole word matches Windows XP Need to improve speed of Excel macro that searches for whole word matches Office 2010 32bit
Competent Performer
Need to improve speed of Excel macro that searches for whole word matches
 
Join Date: Jun 2006
Posts: 102
Marrick13 will become famous soon enough
Default

Sorry about that. I threw that database together just for testing purposes (to protect the real data's privacy) and I didn't prepare it properly to illustrate what I was looking for. I also assumed you understood that a whole word match meant that such a search would include words that had adjacent punctuation or special characters and exclude those with adjacent letters or numbers. Anyway, thanks again!
Reply With Quote
Reply

Tags
case, search, whole word match

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to speed up macro AC PORTA VIA Excel 3 10-30-2015 08:58 PM
Excel formula required to speed up process of creating species rarefaction curves. Ecology! Tim_F Excel 2 07-18-2014 04:56 AM
Need to improve speed of Excel macro that searches for whole word matches word and keyboard speed ptz Word 2 09-20-2012 06:37 AM
Need to improve speed of Excel macro that searches for whole word matches Help -can i improve this way of working? lucky67 Office 1 01-26-2012 09:20 PM
Need to improve speed of Excel macro that searches for whole word matches Change how windows searches cadams Office 1 12-07-2010 10:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft