+ Reply to Thread
Results 1 to 13 of 13

Checking that a cell contains 4letters then 7 numbers

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

    Post Checking that a cell contains 4letters then 7 numbers

    In my line of work we use sea-cans to transport a great deal of goods.
    The sea-cans are always tracked by an 11 digit code which is 4 letters followed by 7 numbers.
    Example: ABCD1234567

    When I am entering these sea-cans into our database, sometimes a number is missed, or an extra one is entered, etc.
    I'm looking to create some sort of highlight-cell function or IF function to return the cell red if it does not contain exactly 11 digits (4 letters followed by 7 numbers).

    Any help would be greatly appreciated!

    Regan
    Last edited by ReganK; 05-08-2018 at 02:40 PM. Reason: Meant to be 7 numbers

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Checking that a cell contains 4letters then 7 numbers

    In sheet module, values in column A.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

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

    Re: Checking that a cell contains 4letters then 7 numbers

    Awesome, this looks like exactly what I was after!
    Thanks so much!
    I'm just having trouble switching it up to apply to a single cell (in a template that we constantly use)
    I'm using excel 2013 - would this affect it any?

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Checking that a cell contains 4letters then 7 numbers

    Hello ReganK,

    I'm just having trouble switching it up to apply to a single cell
    Can you tell us which single cell, please?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Checking that a cell contains 4letters then 7 numbers

    Hi ReganK,

    You could also try

    Please Login or Register  to view this content.

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

    Re: Checking that a cell contains 4letters then 7 numbers

    G7 is the cell in our manifest where we input the Can #s
    (where would I be putting this formula in? I've only used '=' in a cell for a formula before, this is new to me sorry)

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Checking that a cell contains 4letters then 7 numbers

    Thank you, ReganK,

    Then try,

    Please Login or Register  to view this content.
    Regards.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Checking that a cell contains 4letters then 7 numbers

    Right click on Template sheet tab and select View Code.

    Paste the code in the window on the right.

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

    Re: Checking that a cell contains 4letters then 7 numbers

    Thanks a ton! Got it to work - life saver!

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Checking that a cell contains 4letters then 7 numbers

    Glad to help and thanks for rep+.

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Checking that a cell contains 4letters then 7 numbers

    Hi ReganK,

    In Post#3, you state;
    Awesome, this looks like exactly what I was after!
    Thanks so much!
    I'm just having trouble switching it up to apply to a single cell (in a template that we constantly use)
    That made me believe you knew where to enter the Code.

    Glad you got it right, and thank you for the Rep+. Much appreciated!

    Regards.

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

    Re: Checking that a cell contains 4letters then 7 numbers

    *Updating the form some more*

    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

  13. #13
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Checking that a cell contains 4letters then 7 numbers

    These patterns seem to work.
    Please Login or Register  to view this content.

+ 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. checking numbers if they are identical
    By fric in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-29-2017, 08:46 AM
  2. Need help checking bingo numbers
    By kkaistha in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2015, 10:07 AM
  3. [SOLVED] Checking if 20 consecutive numbers in a raw are below a given value
    By Brool in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-21-2015, 07:39 AM
  4. Checking for numbers in string
    By ramserp in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 12-07-2009, 04:05 AM
  5. Checking for Negative Numbers
    By andyb400 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-03-2009, 07:07 PM
  6. Checking crossword numbers
    By shanjar in forum Excel General
    Replies: 1
    Last Post: 04-07-2006, 05:15 PM
  7. [SOLVED] Checking numbers in range
    By Jan Kronsell in forum Excel General
    Replies: 14
    Last Post: 01-15-2006, 06:35 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