Results 1 to 4 of 4

Validate values within a string based on a reference string

Threaded View

  1. #1
    Registered User
    Join Date
    04-09-2021
    Location
    London, England
    MS-Off Ver
    Microsoft 365
    Posts
    2

    Validate values within a string based on a reference string

    I have user-input strings of size codes in one column which follow this format:
    [3][4][5][6][7][8][9][10][11][12][13][14][15][16][17]
    [3][3-][4][4-][5][5-][6][6-][7][7-][8][9]
    [XS][S][M][L][XL]

    The input could be any length, and the values may not be in order, but they should always be delimited using square brackets.
    I need to validate these user-input strings against another column which contains a string of all possible values for that row, e.g.

    [3][3-][4][4-][5][4-][6][6-][7][7-][8][8-][9][9-][10][10-][11][11-][12][12-][13][13-][14][14-][15][16][17]
    [XXS][XS][S][M][L][XL][XXL][3XL][4XL]

    Again these reference strings could be slightly different for each row, and they might not be the same length, however within the reference the delimiters will always be correct and the sizes will always be in a specific order, even if some are missing.

    The validation needs to do two things:
    - Check that the delimiters used are correct (no typos)
    - Check that there are no values within the user-input string that are not contained in the reference.

    If the user input contained a fixed number of values and all possible values within the string had the same character length I could do this relatively easily using an inelegant combination of LEN() and SUBSTITUTE() functions, but I'm struggling to factor in the variable lengths of both value and string: the different value lengths and the fact that some values contain others (e.g. 13 and 3- both contain 3, XXL contains both XL and L) will play havoc with the SUBSTITUTE() function and the variable number of values contained within a string makes it impossible to tell the formula how many substitutions to make, unless I use VBA loops which I really don't want to do.

    I know this would be a lot easier if the validation reference was a list rather than a string, but I can't change this as it's fetched from a database. Nor can I add helper columns to the table to split the user input values out because it will mess up a load of database commit procedures.

    I've also tried using SEARCH() with wildcards but this is not at all reliable.

    Am I being stupid, is there a simple answer here? Or am I going to have to crack open the VBA editor for this one?
    Attached Files Attached Files
    Last edited by KF91; 04-09-2021 at 10:53 AM. Reason: Adding attachment

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Reference an object via a string (Convert a string to an objejct reference
    By grazian2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-16-2015, 11:47 AM
  2. Replies: 1
    Last Post: 08-07-2015, 04:01 PM
  3. Script to Search for a specific String then return cell values above that String-4
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2015, 01:28 AM
  4. [SOLVED] Script to Search for a specific String then return cell values above that String-3
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2015, 01:50 PM
  5. [SOLVED] Script to Search for a specific String then return cell values above that String-2
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2015, 01:00 PM
  6. [SOLVED] Script to Search for a specific String then return cell values above that String
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2015, 11:28 AM
  7. Replies: 5
    Last Post: 11-08-2012, 03:38 PM

Tags for this Thread

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