+ Reply to Thread
Results 1 to 16 of 16

Checking that certain cells contain specific numbers

  1. #1
    Registered User
    Join Date
    05-08-2018
    Location
    Hazelton, Canada
    MS-Off Ver
    2013
    Posts
    19

    Checking that certain cells contain specific numbers

    My job uses a lot of C-cans which are labeled as 4 letters followed by 7 numbers, and contain different material inside them that is also numbered.
    On the packing slips I generate for this cargo it is very important to not have any mistakes - so I had help making a macro to turn cells RED if they didn't contain the correct info ie."4 letters followed by 7 numbers". (See below for the Can# check)

    Please Login or Register  to view this content.
    I'd like to do something similar for multiple other boxes. Some things to add are:
    1) Cell C5 must contain the text "Shipment #" followed by 2 numbers [0-9]{2} example: Shipment # 02
    2) Cell C7 must contain the text "Seal # UL-" followed by 7 numbers [0-9]{7} example: Seal # UL-1234567
    3) Cell G5 must contain the date in format of 11.11.11
    4) Cell G6 must contain 8 numbers followed by a "-" then 2 numbers example: 12341234-12

    5) Then cells B18->B26, F18->26, G18->26, and G38 must contain at least 1 number.

    I've tried tackling this on my own - for instance for #1, with stuff like:

    Please Login or Register  to view this content.

    but I'm not so familiar with how these things work, or where I should be copy and pasting that code to. Ie. within the sub of the last macro? on a new one with the option explicit text again? etc.
    (Attached a blank copy of the form I'm using)

    Any help would be greatly appreciated!! Thanks in advance
    Attached Files Attached Files
    Last edited by ReganK; 08-26-2018 at 04:04 PM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Checking that certain cells contain specific numbers

    What's the use of a blank file to help you?
    I'm not going to fill in data,
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    05-08-2018
    Location
    Hazelton, Canada
    MS-Off Ver
    2013
    Posts
    19

    Re: Checking that certain cells contain specific numbers

    O sorry - good catch! Filled it in with what it would look like approximately

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Checking that certain cells contain specific numbers

    Thanks, I'll take a look, is bed-time here so won't 'til tomorrow

  5. #5
    Registered User
    Join Date
    05-08-2018
    Location
    Hazelton, Canada
    MS-Off Ver
    2013
    Posts
    19

    Re: Checking that certain cells contain specific numbers

    Thanks in advance!! I'll be here

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Checking that certain cells contain specific numbers

    Since you're still awake

    Try this.

    Please Login or Register  to view this content.
    Good-night

  7. #7
    Registered User
    Join Date
    05-08-2018
    Location
    Hazelton, Canada
    MS-Off Ver
    2013
    Posts
    19

    Re: Checking that certain cells contain specific numbers

    This is great!
    One issue I'm getting is that for the G6 column, the Target.Text approach seems to be bugging out if I delete all the contents of the cell.
    It will also allow for only 1 digit on the left side of the "-", something with trimming the target text must be bugged?

    Please Login or Register  to view this content.
    Was just looking over this - and if possible - another great feature would be for IF B18 has contents, then F18 and G18 must as well. (Could be in any order)
    ex. if F18 has contents then B18 and G18 must as well, etc.
    ie. If i have any info across the slip then I must have all the info

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Checking that certain cells contain specific numbers

    Quote Originally Posted by ReganK View Post
    I'd like to do something similar for multiple other boxes. Some things to add are:
    1) Cell C5 must contain the text "Shipment #" followed by 2 numbers [0-9]{2} example: Shipment # 02
    2) Cell C7 must contain the text "Seal # UL-" followed by 7 numbers [0-9]{7} example: Seal # UL-1234567
    3) Cell G5 must contain the date in format of 11.11.11
    4) Cell G6 must contain 8 numbers followed by a "-" then 2 numbers example: 12341234-12

    5) Then cells B18->B26, F18->26, G18->26, and G38 must contain at least 1 number.

    Any help would be greatly appreciated!! Thanks in advance
    Try
    Please Login or Register  to view this content.
    Last edited by jindon; 08-26-2018 at 10:38 PM.

  9. #9
    Registered User
    Join Date
    05-08-2018
    Location
    Hazelton, Canada
    MS-Off Ver
    2013
    Posts
    19

    Re: Checking that certain cells contain specific numbers

    Ahhh String functions! Makes that a lot simpler - thanks a ton!
    Is there a way I could add one to check:

    IF B18 has contents, then F18 and G18 must as well. (Could be in any order)
    ex. if F18 has contents then B18 and G18 must as well, etc.
    Similarily: if F17 has contents then B17 and G17 must as well

    ie. If i have any info across the slip then I must have all the info
    Item # / box / weight

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Checking that certain cells contain specific numbers

    Well, now's the time to set the grey matter to work and try out yourself, you've got the code, Jindon's is the best one, all you need now is the extra conditions and you could even do that with conditional formatting.

  11. #11
    Registered User
    Join Date
    05-08-2018
    Location
    Hazelton, Canada
    MS-Off Ver
    2013
    Posts
    19

    Re: Checking that certain cells contain specific numbers

    Thanks again !

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Checking that certain cells contain specific numbers

    Just holler if you get stuck

    Off to bed here.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Checking that certain cells contain specific numbers

    Quote Originally Posted by ReganK View Post
    IF B18 has contents, then F18 and G18 must as well. (Could be in any order)
    ex. if F18 has contents then B18 and G18 must as well, etc.
    Similarily: if F17 has contents then B17 and G17 must as well

    ie. If i have any info across the slip then I must have all the info
    Item # / box / weight
    See if this is how you wanted.
    Edit:Missed col.B and fixed.
    Please Login or Register  to view this content.
    Last edited by jindon; 08-28-2018 at 04:54 AM.

  14. #14
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Checking that certain cells contain specific numbers

    Even though it was marked solved ....
    For some reason I couldn't get Jindon's code to work so I took the liberty of editing it and it looks like it's Okay now.
    Excuse the intrussion
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    05-08-2018
    Location
    Hazelton, Canada
    MS-Off Ver
    2013
    Posts
    19

    Re: Checking that certain cells contain specific numbers

    You guys are the best!! <3 Thanks so much for all this help - the file is fool proof now! :D

  16. #16
    Registered User
    Join Date
    05-08-2018
    Location
    Hazelton, Canada
    MS-Off Ver
    2013
    Posts
    19

    Re: Checking that certain cells contain specific numbers

    Thanks so much for all your help!! The file is amazing now - hoping no one will ever miss filling out a box now! Awesome work

+ 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 for checking the configurations of 5 numbers in "master cells" and save the result
    By BalanF in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2017, 05:42 AM
  2. Delete cells that don't contain specific numbers
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-29-2014, 11:15 AM
  3. checking two range of data base on an specific cells value with VBA or formula
    By hamidrezaxy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2013, 05:10 PM
  4. [SOLVED] [Question] Checking a range of cells if they contains a specific letter
    By MyOnion in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-18-2013, 01:01 AM
  5. Replies: 15
    Last Post: 10-11-2009, 11:46 AM
  6. Trying to take an average of numbers in specific cells...
    By corty_d in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-13-2008, 12:57 PM
  7. [SOLVED] How do I count cells that contain one of several specific numbers?
    By Lewis0205NC in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-21-2006, 09:30 AM

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