Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-08-2011, 06:08 AM
joblo108 joblo108 is offline AND/OR/NOT-search Windows XP AND/OR/NOT-search Office 2003
Novice
AND/OR/NOT-search
 
Join Date: Sep 2011
Posts: 2
joblo108 is on a distinguished road
Default AND/OR/NOT-search

I am using an Excel-file consisting of a few thousand rows and three columns. Column three consists of text descriptions, and I want to search these cells for multiple keywords. It seems to be difficult to do this in Excel – I can only search for singular words or strings of text.

Is it possible to do an AND/OR/NOT-type of search in Excel, or do somebody have a suggestion about how I could do that in some other way? I have tried to copy the spreadsheet to MS Access but the cells contain to much text for Access.

I appreciate any tip.

/Johan
Reply With Quote
  #2  
Old 09-08-2011, 07:03 AM
Catalin.B Catalin.B is offline AND/OR/NOT-search Windows Vista AND/OR/NOT-search Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

There is a good macro you can use, made by hiker95: (same macro in sample attached) You can enter in sheet Keywords how many keywords you need , the limit is the number of excel rows...
Code:
Option Explicit
Option Base 1
Sub CKKeywords()
Dim c As Range, a As Long, b As Long
Dim MyKeys As Variant
Application.ScreenUpdating = False
MyKeys = Sheets("Keywords").Range("A2:A" & Sheets("Keywords").Cells(Rows.Count, 1).End(xlUp).Row)
With Sheets("Sheet1")
  For Each c In .Range("C1", .Range("C" & Rows.Count).End(xlUp))
    For a = LBound(MyKeys) To UBound(MyKeys)
      b = 0
      On Error Resume Next
      b = WorksheetFunction.Find(Trim(MyKeys(a, 1)), c, 1)
      On Error GoTo 0
      If b > 0 Then
        c.Offset(, 1) = "Yes"
        Exit For
      End If
    Next a
  Next c
End With
Application.ScreenUpdating = True
End Sub
Attached Files
File Type: xlsm search after multiple keywords.xlsm (16.4 KB, 9 views)
Reply With Quote
  #3  
Old 09-09-2011, 02:59 AM
joblo108 joblo108 is offline AND/OR/NOT-search Windows XP AND/OR/NOT-search Office 2003
Novice
AND/OR/NOT-search
 
Join Date: Sep 2011
Posts: 2
joblo108 is on a distinguished road
Default

Hi

I am trying to run the macro but I get a “runtime error no 9: the index is outside of interval”. I’m a newb when it comes to MS Excel and programming. The problem is in the line

MyKeys = Sheets("Keywords").Range("A2:A" & Sheets("Keywords").Cells(Rows.Count, 1).End(xlUp).Row)

of the macro.

How should I change it to conform with my spreadsheet?

Thanks for your help!

/Johan
Reply With Quote
  #4  
Old 09-09-2011, 04:23 AM
Catalin.B Catalin.B is offline AND/OR/NOT-search Windows Vista AND/OR/NOT-search Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

Quote:
Originally Posted by joblo108 View Post
Hi

The problem is in the line

MyKeys = Sheets("Keywords").Range("A2:A" & Sheets("Keywords").Cells(Rows.Count, 1).End(xlUp).Row)

of the macro.

How should I change it to conform with my spreadsheet?

Thanks for your help!

/Johan
Make sure you have a sheet named Keywords, which has your keywords in column A starting from cell A2
This part of the code assumes that your data to evaluate is in Sheet1; if not, rename worksheet as Sheet1, or type in this part of the code the name of your sheet with data; this code assumes that data range is column C; if not, change the column letter...
Code:
With Sheets("Sheet1")
  For Each c In .Range("C1", .Range("C" & Rows.Count).End(xlUp))
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
AND/OR/NOT-search Search Function Rick203 Outlook 1 08-29-2011 11:23 PM
Instant Search's "Display search results as I type when possible" with Exchange lwc Outlook 0 06-01-2011 01:56 AM
Search for an attachment Pryach Outlook 0 06-15-2010 09:36 AM
Search and Replace - Clear Search box JostClan Word 1 05-04-2010 08:46 PM
Wildcard search help. Kempston Word 0 11-13-2009 03:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:26 PM.


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