+ Reply to Thread
Results 1 to 6 of 6

Validation specific characters in a string of characters

  1. #1
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2010
    Posts
    25

    Validation specific characters in a string of characters

    Hi Everyone,

    Is there a VBA way to validate if certain characters in a string of characters have specific values. For instance, take the following string:

    07001362CA39DN7000002269 20140810 000099999999

    Say I want to verify if characters 23 and 24 ("69") are between "67" and "71" , and if they are not, to change their color to red.

    Thanks guys!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: Validation specific characters in a string of characters

    This sub will do that:
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: Validation specific characters in a string of characters

    This is designed to be called by another VBA Sub. If you need something that operates on the current cell, then try
    This sub will do that:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Validation specific characters in a string of characters

    That's very helpful Thanks!

  5. #5
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Validation specific characters in a string of characters

    Any thoughts on why If I try to change to the range for say Set C = Range("A:A") or Set C = Range("A11:A30") , I get a type mismatch error?

    Thanks

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: Validation specific characters in a string of characters

    Yes, because this code is designed to look at one cell at a time. What are you trying to accomplish by changing it to a range? Do you want to limit which cells are included in this check, rather than do it for any cell on the sheet? How are you using the macro?

+ 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] VBA, remove all characters within a string, except numerical characters and full stops
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-25-2015, 09:24 PM
  2. [SOLVED] Macro to create a new line within a text string if specific characters appear mid-string
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-29-2014, 11:32 AM
  3. [SOLVED] get characters after the specific nth string
    By itselflearn in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-22-2013, 05:14 PM
  4. [SOLVED] Extract left characters from string with exception of 2 right characters
    By sweetkel23 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-16-2012, 10:45 PM
  5. [SOLVED] Need to capture a specific string of characters
    By saccer in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-24-2012, 01:10 AM
  6. Return string between two specific characters
    By kaytoo in forum Excel General
    Replies: 6
    Last Post: 12-19-2006, 03:00 AM
  7. Text String - Specific Characters
    By Kiser in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-09-2006, 10:50 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