+ Reply to Thread
Results 1 to 5 of 5

Subnetting Validation

  1. #1
    Registered User
    Join Date
    09-27-2015
    Location
    AZ
    MS-Off Ver
    2010
    Posts
    23

    Subnetting Validation

    Hello -

    I found a formula that will validate if the IP address that I enter in a cell is correct:

    Please Login or Register  to view this content.
    However, I this validation is only for the ip address (for example, 192.168.1.1).

    I need to validate the user is entering the correct IP with subnet information (for example, 192.168.1.1/24).

    Is there a way to modify this validation to look for the subnet cdr at the end of the IP? (/32, /31, /30..... /1).

    Thanks,

    Scott

  2. #2
    Forum Guru XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    6,899

    Re: Subnetting Validation

    Hi,

    I'm not quite sure what your level of validation is here. For example, your current formula does nothing to disallow extra digits within the string: both

    192.168.1.1.999

    and

    192.0168.1.1

    to give just two examples, would both be admitted by your current validation formula.

    As to your question, an abbreviated version of your current formula would be.

    =SUMPRODUCT(N(LOG(1+MID(SUBSTITUTE(B1,".",REPT(" ",10)),{1,11,21,31},10),2)<=8))

    Is there a reason we can't just add a further condition to the above (or to your current formula) to check that the last two digits are >=0 and <=32?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    09-27-2015
    Location
    AZ
    MS-Off Ver
    2010
    Posts
    23

    Re: Subnetting Validation

    Thanks for your response!

    Looks like you are correct. My long validation does not really work properly.

    I like your simplified version. But not really sure I understand it. Plus it seems to output a value instead of true or false (192.168.1.1 = 4).

    I should have put more detail in my original post.

    My goal is to validate IP subnet so the address is somewhere between 0.0.0.0 and 255.255.255.255 and the cider at the end of the block is between /1 and /32.

    For example:
    192.168.1.1/24 = TRUE
    100.64.0.0/16 = TRUE
    1000.10.10.0/24 = FALSE
    10.10.10.0/45 = FALSE

    (I know the formula will not catch incorrect ip blocks... But this should catch little mistakes and makes sure the user enters the data in the field properly.)

    Seems like there would be an easy way to do this... Just not sure what it would be. Thanks again for looking at this for me! Really appreciate your help!

  4. #4
    Forum Guru XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    6,899

    Re: Subnetting Validation

    Ok, if you're happy with a minimal level of validation as discussed:

    =SUMPRODUCT(N(LOG(1+MID(SUBSTITUTE(SUBSTITUTE(B1,"/","."),".",REPT(" ",10)),{1,11,21,31,41},10),2)<={8,8,8,8,5}))=5

    Regards

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    mysore
    MS-Off Ver
    Excel 2007
    Posts
    4,608

    Re: Subnetting Validation

    We can try this also for A2

    =AND(ISNUMBER(FIND("/",A2)),SUMPRODUCT(N(LOG(1+MID(SUBSTITUTE(SUBSTITUTE(A2,"/","."),".",REPT(" ",10)),{1,11,21,31,41},10),2)<={8,8,8,8,5}))=5)
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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