Advertisement

03.11.2008 at 06:20AM PDT, ID: 23231570
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Find any part of a text string within a range
Tags: Excel, VBA
Hi all,
I am looking for function or routine in Excel/VBA that will search for any part of a text string in a given range. Like, in collumn E I observe that a cell contains: DANSKE BANK A/S 5.125 2009-11-12, and in collumn D I observe a cell (or several cells) that contains: DANSKE BANK AS. What I would like is a function or a vba routine that realises that "DANSKE BANK A/S 5.125 2009-11-12" contains words that you will find in cells in colloum D, namely: "DANSKE BANK". Sort of an advanced VLOOKUP - that does not need to have an exact match as long as at least one or two words are the same. So, say, in collumn F I would like to have returned: "DANSKE BANK AS".

Is this workable?

Thanks,
Wiley

Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: WileyPowers
Solution Provided By: GrahamSkan
Participating Experts: 3
Solution Grade: A
Views: 386
Translate:
Loading Advertisement...
03.11.2008 at 06:50AM PDT, ID: 21095671

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 07:02AM PDT, ID: 21095781

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 07:09AM PDT, ID: 21095824

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 07:19AM PDT, ID: 21095912

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 07:30AM PDT, ID: 21096023

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 07:36AM PDT, ID: 21096086

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 07:54AM PDT, ID: 21096270

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 07:57AM PDT, ID: 21096297

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 08:40AM PDT, ID: 21096790

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 12:11PM PDT, ID: 21098971

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.11.2008 at 11:21PM PDT, ID: 21103479

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.12.2008 at 01:00AM PDT, ID: 21103819

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.12.2008 at 02:12AM PDT, ID: 21104075

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.12.2008 at 02:46AM PDT, ID: 21104217

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.12.2008 at 04:07AM PDT, ID: 21104638

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.11.2008 at 06:50AM PDT, ID: 21095671
Have you tried the FIND function? You could nest with an IF statement to return the value you want displayed in Column F
 
03.11.2008 at 07:02AM PDT, ID: 21095781
I think the problem with such an approach is that you will never know which part of the text string in collumn E that will match a matching word in column D?
 
03.11.2008 at 07:09AM PDT, ID: 21095824
Let me ask for clarification - on any given row of data - you are wanting to compare col D & E and return the common portion of text string in Col F?  So, you aren't specifying what you are looking for, you want the match to happen via formula/VBA?
 
03.11.2008 at 07:19AM PDT, ID: 21095912

Rank: Genius

You may want to have a look at this page for some ideas: http://www.mrexcel.com/pc07.shtml
Note that if you have a lot of values to compare, it will be very slow. Also, from your original example, I assume you meant that you expected "DANSKE BANK" to be returned, since the AS part does not appear in both texts you were comparing?
Regards,
Rory
 
03.11.2008 at 07:30AM PDT, ID: 21096023
LMPhillips - that is correct.
 
03.11.2008 at 07:36AM PDT, ID: 21096086
rorya: thanks for the tip. btw, initially i was thinking that it is DANSKE BANK AS that i would like it to return, and not only the matching words - but, that would also work out.

do you have any spesific suggestions?

thanks,
wiley
 
03.11.2008 at 07:54AM PDT, ID: 21096270

Rank: Genius

Not really - at the moment I think the requirement is too vague and you would get lots of false lookups. Words like 'the' and 'and' would cause problems; should numbers be matched; what do you do if there's more than one match (but against different data) and so on. If you have a lot of data, then if you used a VBA function, I think your worksheet would grind to a halt, so you would be better off with a macro run manually.
There is a Fuzzy Finder add-in you can buy for Excel, if that's an option. Alternatively, you might be able to adapt Google's technology: http://www.google.com/technology/pigeonrank.html  ;-P
Regards,
Rory
 
03.11.2008 at 07:57AM PDT, ID: 21096297
rorya - thanks
 
03.11.2008 at 08:40AM PDT, ID: 21096790
Is the text that you are wanting to match always at the front of the string?
 
03.11.2008 at 12:11PM PDT, ID: 21098971

Rank: Genius

You could start with this macro, and see how it suits you.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
Option Explicit
Option Compare Text
 
Sub FindCommonWords()
    Dim strDWords() As String
    Dim strEWords() As String
    Dim sh As Worksheet
    
    Set sh = ActiveSheet
    Dim r As Integer
    Dim d As Integer
    Dim e As Integer
    r = 1
    Do Until sh.Cells(r, 4) = ""
        strDWords = Split(sh.Cells(r, 4), " ")
        strEWords = Split(sh.Cells(r, 5), " ")
        
        For d = 0 To UBound(strDWords)
            For e = 0 To UBound(strEWords)
                If strDWords(d) = strEWords(e) Then
                    sh.Cells(r, 6) = Trim$(sh.Cells(r, 6) & " " & strDWords(d))
                End If
            Next e
        Next d
        r = r + 1
    Loop
End Sub
Open in New Window
 
03.11.2008 at 11:21PM PDT, ID: 21103479
LMPhillips: No, potential matching word can be anywhere within the string (or not at all).
GrahamSkan: Thanks for your contribution - I'm currently looking into it.

Rgds,
Wiley
 
03.12.2008 at 01:00AM PDT, ID: 21103819
GrahamSkan:Nice suggestion.Still, this routine will only compare columns 4 and 5 row by row. If this could be tweeked so that it loops thru collumn 4 for each cell in collumn 5 in its search for matching words, then, it would work optimally.

Is this doable?

Thanks,
Wiley
 
03.12.2008 at 02:12AM PDT, ID: 21104075

Rank: Genius

This will list in column F each word that is found in both columns C and D
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
Option Explicit
Option Compare Text
 
Sub FindCommonWords()
    Dim strDWords() As String
    Dim strEWords() As String
    Dim sh As Worksheet
    Dim iDWords As Integer
    Dim iEWords As Integer
    Dim lDRow As Integer
    Dim lERow As Integer
    Dim lFRow As Integer
    Dim bFound As Boolean
    Set sh = ActiveSheet
    lDRow = 1
    Do Until sh.Cells(lDRow, 4) = ""
        strDWords = Split(sh.Cells(lDRow, 4), " ")
        For iDWords = 0 To UBound(strDWords)
            lERow = 1
            Do Until sh.Cells(lERow, 4) = ""
                strEWords = Split(sh.Cells(lERow, 5), " ")
                    For iEWords = 0 To UBound(strEWords)
                        If strDWords(iDWords) = strEWords(iEWords) Then
                            lFRow = 1
                            Do Until sh.Cells(lFRow, 6) = ""
                                If sh.Cells(lFRow, 6) = strDWords(iDWords) Then
                                    Exit Do
                                End If
                                lFRow = lFRow + 1
                            Loop
                            sh.Cells(lFRow, 6) = strDWords(iDWords)
                            Debug.Print sh.Cells(lFRow, 6), lFRow
                        End If
                    Next iEWords
                lERow = lERow + 1
            Loop
        Next iDWords
        lDRow = lDRow + 1
    Loop
End Sub
Open in New Window
 
03.12.2008 at 02:46AM PDT, ID: 21104217
Very good. But a final wish - can you tweak it so that: 1) the mathcing words that are being written to collumn F are positioned in the corresponding row to E (and not like a list on top of collumn F), and 2) that all the instances of words that match are written to F - not only the unique instances.

Thanks,
Wiley
 
03.12.2008 at 04:07AM PDT, ID: 21104638

Rank: Genius

That makes it a bit longer to ensure that the word does not get reported more than once in each cell in column F.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
Option Explicit
Option Compare Text
 
Sub FindCommonWords()
    Dim strDWords() As String
    Dim strEWords() As String
    Dim strFWords() As String
    Dim sh As Worksheet
    Dim iDWords As Integer
    Dim iEWords As Integer
    Dim iFWords As Integer
    Dim iFWordCount As Integer
    Dim lDCol As Long
    Dim lECol As Long
    Dim bFound As Boolean
    
    Set sh = ActiveSheet
    lDCol = 1
    Do Until sh.Cells(lDCol, 4) = ""
        strDWords = Split(sh.Cells(lDCol, 4), " ")
        For iDWords = 0 To UBound(strDWords)
            lECol = 1
            Do Until sh.Cells(lECol, 4) = ""
                strEWords = Split(sh.Cells(lECol, 5), " ")
                    For iEWords = 0 To UBound(strEWords)
                        If strDWords(iDWords) = strEWords(iEWords) Then
                            If sh.Cells(lECol, 6) <> "" Then
                                strFWords = Split(sh.Cells(lECol, 6), " ")
                                iFWordCount = UBound(strFWords)
                                bFound = False
                                For iFWords = 0 To iFWordCount
                                    If strFWords(iFWords) = strDWords(iDWords) Then
                                        bFound = True
                                        Exit For
                                    End If
                                Next iFWords
                                If Not bFound Then
                                    ReDim Preserve strFWords(iFWordCount + 1)
                                    strFWords(iFWordCount + 1) = strDWords(iDWords)
                                    sh.Cells(lECol, 6) = Join(strFWords, " ")
                                End If
                            Else
                                sh.Cells(lECol, 6) = strDWords(iDWords)
                            End If
                        End If
                    Next iEWords
                lECol = lECol + 1
            Loop
        Next iDWords
        lDCol = lDCol + 1
    Loop
End Sub
Open in New Window
Accepted Solution
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628