+ Reply to Thread
Results 1 to 10 of 10

Use inputbox and check regex pattern

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,779

    Use inputbox and check regex pattern

    Hello everyone

    How can I check the entry from the inputbox to match specific pattern ..
    The pattern is 4 digits followed by hyphen (or space before and after hyphen) then two digits
    example : 5148 - 52 or 5148-52 (both are correct)

    Thanks advanced for help
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    8,730

    Re: Use inputbox and check regex pattern

    Perhaps ... Or must it be making use of regex
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere.....
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember......Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,779

    Re: Use inputbox and check regex pattern

    Thanks a lot sintek for your solution. It is great
    In fact I am learning about regex so I prefer using regex .. I think pattern would be
    Please Login or Register  to view this content.
    But I couldn't deal with the spaces ...
    Another point I need to learn how to check the pattern if correct or not

    I have tried and could do it
    Please Login or Register  to view this content.
    Now just the point of checking ...

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    8,730

    Re: Use inputbox and check regex pattern

    Yeah me too...lol
    also struggling with space or space not
    Please Login or Register  to view this content.
    Edit ....
    Please Login or Register  to view this content.
    Last edited by sintek; 08-30-2018 at 01:23 PM.

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,779

    Re: Use inputbox and check regex pattern

    Great. With your pattern this 5148-52 is incorrect
    And with my pattern 5148-52 is correct and 5148 - 52 is correct .. and the problem is that 5148 -52 and 5148- 52 are correct (and this is not desired)

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    8,730

    Re: Use inputbox and check regex pattern

    This works for both ...
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,779

    Re: Use inputbox and check regex pattern

    Thanks but the same problem >>
    the problem is that 5148 -52 and 5148- 52 are correct (and this is not desired)

    I mean there would be space before and after hyphen or no spaces at all .... but not mixed

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,779

    Re: Use inputbox and check regex pattern

    This pattern at last solved the problem
    Please Login or Register  to view this content.
    Thanks a lot for great help

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    8,730

    Re: Use inputbox and check regex pattern

    Awesome...Tx for sharing...

    Check out this link...works wellhttps://www.regextester.com/94189

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,779

    Re: Use inputbox and check regex pattern

    Thanks a lot for your great help. You have helped me a lot in this topic
    Regards

+ 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. [SOLVED] Pattern for regex that matches one digit at least
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-10-2018, 01:57 AM
  2. RegEx - Pattern Matching
    By paularthur90 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2017, 09:16 AM
  3. Need to Define RegEx pattern
    By hmr2662 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-09-2015, 09:24 AM
  4. RegEx pattern
    By capson in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 02-15-2015, 06:57 PM
  5. [SOLVED] RegEx pattern, code exacuting but doing nothing
    By capson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-23-2015, 03:48 PM
  6. Regex - establishing a pattern
    By twckfa16 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-30-2014, 11:06 AM
  7. Need a new regex .pattern for comparison code
    By Swiss Cheese in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2012, 09:16 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