+ Reply to Thread
Results 1 to 5 of 5

Checking cell contents for wildcard-suffixed values without hardcoding the search term

  1. #1
    Registered User
    Join Date
    09-22-2016
    Location
    TO, ON, CA
    MS-Off Ver
    2007
    Posts
    10

    Checking cell contents for wildcard-suffixed values without hardcoding the search term

    Hello All,

    In attempting to port an Access database/report to Excel, I would like to come up with a way to replicate the logic of the following Access query, but without actually hardcoding the values that are being checked for (in a field/column).

    Currently, during the many organization restructures/department name changes, the services of a tech-savvy (SQL-aware) user is required to maintain/change these queries, but I would like for an ordinary user to make changes in a table, without having to touch/change an Excel formula when changes occur.

    Please Login or Register  to view this content.
    So, in the code above, [Business Group] would be a column in Excel, and I would like to check the value of each cell in that column (for all rows of course) to see if it begins with the word "Renewable", but without actually hardcoding the "Renewable*" into the formula.

    Likewise, cells in the column named [Division] have to be checked to see if they begin with words such as "Southwest", "Northwest" etc., but again, those wildcard-suffixed terms must not be embedded in the formula, but rather, be looked-up in a user-maintainable table.

    Is this do-able, and if yes, what would the formula be, and how would I setup the table?

    Thanks

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Checking cell contents for wildcard-suffixed values without hardcoding the search term

    It would help a lot if you could provide a sample workbook and a bit more of an explanation. I think what you are looking for is a "translation" table so XYZ* translates XYZ123 and XYZABC into XYZ Company. Am I getting the idea?

    I suspect the result will depend upon using a combination of LEFT and LEN and VLOOKUP - possibly a VLOOKUP entered as an array formula.

    Fortunately you have Excel 2007 which means you have tables, so formulas are replicated for you automatically.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Checking cell contents for wildcard-suffixed values without hardcoding the search term

    I gave it some more thought. I think VB is the way to go with this issue. The attached workbook has a function to looks at the begin with string, gets the length, compares it with the left portion of the string to evaluate, and if it finds a match, returns the translates to.

    The blue table is the "data table" and the orange table is the Lookup Table. It is called "Table_Lookup." If you want to call it something else, change this line of code:
    For Each cl In Range("Table_Lookup[Begins With]")

    You could move the lookup table to another sheet.

    Also if you want to get fancy, I could change the code so instead of just matching begins with, the user can supply the pattern they want such as XYZ* for begins with, *XYZ for ends with or *XYZ* has XYZ anywhere.

    The existing code doesn't use the * we don't need it if it's always begins with.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-22-2016
    Location
    TO, ON, CA
    MS-Off Ver
    2007
    Posts
    10

    Re: Checking cell contents for wildcard-suffixed values without hardcoding the search term

    @dflak,

    Much thanks for your reply...and you know what? I guess you could say "great minds think alike!"....since I too had started going down the path of using VBA (not knowing how to achieve it using just formulas and a list/table...and not getting a reply here, and on another Excel forum).

    So, even though I would prefer to only achieve this using formulas (which obviously are much quicker, and not much of a payload), I guess I'd have to do it using an UDF instead.

    I haven't seen your code/workbook as yet, but what I've started my code with is the following:

    Please Login or Register  to view this content.
    Right now, I do have it hard-coded in the code above, but I should easily be able to reference a wildcard-suffixed cell value (from a list/table) instead.

    What do you think?

    I'll take a look at your suggestion as well...perhaps it look better than my solution.

  5. #5
    Registered User
    Join Date
    09-22-2016
    Location
    TO, ON, CA
    MS-Off Ver
    2007
    Posts
    10

    Re: Checking cell contents for wildcard-suffixed values without hardcoding the search term

    Oh, one more thing:

    That last part that you suggested and offered (i.e. getting all fancy with 'begins with", "ends with", "contains" etc.) would indeed be great to have...so would appreciate if you could add that to your code and re-attach.

    Unfortunately, I will not be able to download this file while I'm in the office, and will have to do it once I get home. Will have to ask any further questions on Monday.

    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Return text in cell to the left of search term
    By taniwha in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-10-2016, 05:53 AM
  2. [SOLVED] Using INDEX MATCH to return unique values for non-unique search term
    By rico_suave in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 06-03-2015, 01:53 AM
  3. Replies: 14
    Last Post: 10-30-2014, 02:38 PM
  4. Return multiple values to a UserForm using one search term
    By clapforthewolfman in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-24-2013, 03:37 PM
  5. [SOLVED] Formula to display cell if the text content partially matches a search term
    By Avestron in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-11-2013, 04:07 AM
  6. Checking Cell Contents
    By Paige in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-22-2005, 03:20 PM
  7. Replies: 1
    Last Post: 11-03-2005, 04:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1