{"id":13693,"date":"2017-07-09T06:28:30","date_gmt":"2017-07-09T06:28:30","guid":{"rendered":"http:\/\/learnexcelmacro.com\/wp\/?p=13693"},"modified":"2022-08-05T17:13:12","modified_gmt":"2022-08-05T17:13:12","slug":"bsn-number-validator-using-excel-vba","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2017\/07\/bsn-number-validator-using-excel-vba\/","title":{"rendered":"Validate BurgerServiceNummer (BSN) using Excel VBA"},"content":{"rendered":"
[et_pb_section fb_built=”1″ _builder_version=”4.16″ da_disable_devices=”off|off|off” global_colors_info=”{}” da_is_popup=”off” da_exit_intent=”off” da_has_close=”on” da_alt_close=”off” da_dark_close=”off” da_not_modal=”on” da_is_singular=”off” da_with_loader=”off” da_has_shadow=”on”][et_pb_row _builder_version=”4.16″ background_size=”initial” background_position=”top_left” background_repeat=”repeat” global_colors_info=”{}”][et_pb_column type=”4_4″ _builder_version=”4.16″ custom_padding=”|||” global_colors_info=”{}” custom_padding__hover=”|||”][et_pb_text _builder_version=”4.17.6″ background_size=”initial” background_position=”top_left” background_repeat=”repeat” hover_enabled=”0″ global_colors_info=”{}” sticky_enabled=”0″]<\/p>\n
Important Note: This post will make more sense to those who stay in the Netherlands.
\nAlso do not forget to download the BSN validator tool created at the end of the post. It is FREE to download and play around with. Thanks.<\/p>\n
But wait.. even if you do not stay in the Netherlands, you will learn some interesting Algorithms!!<\/strong><\/em><\/p>\n<\/div>\n In standard Check Digit or 11-Check, individual digits are multiplied by a weighted number and summed up together. If the total sum is divisible by 11. or in other words, if the total sum is a multiple of 11 then, the number passes the 11-Check or Elfproef. Check if 614961122<\/strong> is a valid 11-check number Check if 614961122<\/strong> is a valid 11-check number This is the most important question about any thing you do… What would you do with this? What is the use of it? So this function can be used for checking if entered BSN number is a valid BSN number or not. There are companies or organizations which uses excel as a Data form for the users to enter their details like Name, Date of Birth, Address, BSN etc. In such form, you can implement such validation to prevent from entering an Invalid BSN number.<\/p>\n This code can be used in many different ways, depending on your requirement. You can call this function on clicking on a button to validate the entered BSN number and display the result accordingly.<\/p>\n Another way of using this function can be — using it as a UDF (User Defined Function) or custom function. Where you can use it like a formula to check the validity of the BSN number entered by a user in a cell.<\/p>\n [\/et_pb_text][et_pb_cta title=”Your FREE Workbook to Play around” button_url=”\/excel\/wp-content\/downloads\/BSN-Number-Validator.xlsm” button_text=”Download FREE Workbook” _builder_version=”4.17.6″ _module_preset=”a50a16dd-d05f-4ea2-acab-1468d2e4010e” global_colors_info=”{}”]At last, your free copy of the Excel workbook, which you can download and play around with code.<\/p>\n This workbook has examples of both the usage I explained above.<\/p>\n
\nBSN is the short form of Dutch Word – BurgerServiceNummer . <\/em>In English, this is called \u00a0Citizen Service Number. This is a unique\u00a0Personal Identification Number assigned by Netherlands Govt. This was introduced\u00a0in 2007. To know more about this you can read this wiki page<\/a> or you can refer the NL government website<\/a> about it. This is a 9 digit number which should corresponds to 11-check<\/a> or in dutch Elfproef<\/a><\/em><\/p>\nWhat is Elfproef or 11-Check – Standard<\/h1>\n
\nWeighted Number is the position number of the digit in number from right to Left direction.<\/em><\/div>\nExample:<\/h2>\n
\nTotal sum<\/strong> = 6 * 9<\/strong> + 1*8<\/strong> + 4*7<\/strong> + 9 *6<\/strong> + 6*5<\/strong> + 1*4<\/strong> + 1*3<\/strong> + 2*2<\/strong> + 2*1 = 187<\/strong>
\nCheck if Total sum is divisible by 11 => 187 \/ 11 = 17 ( Remainder = 0)
\nThis means\u00a0614961122<\/strong>\u00a0passes the 11-check standard.
\nWhat is Elfproef or 11-Check – Specific to BSN?
\nA variant of standard Elfproef is used for BSN. There is a small change in the standard. Weighted value for the last digit from Left to Right is changed from 1 to -1<\/strong> . That’s all the deviation from the standard 11-Check.<\/p>\nExample:<\/h2>\n
\nTotal sum<\/strong> = 6 * 9<\/strong> + 1*8<\/strong> + 4*7<\/strong> + 9 *6<\/strong> + 6*5<\/strong> + 1*4<\/strong> + 1*3<\/strong> + 2*2<\/strong> + 2*(-1) = 183<\/strong>
\nCheck if Total sum is divisible by 11 => 183 \/ 11 = 17 ( Remainder = 7)
\nThis means\u00a0614961122<\/strong> is not a VALID BSN Number of Netherlands<\/span>[\/fusion_text][fusion_text][fusion_text]To do this validation easily in Excel, I created a Excel VBA function using above Algorithm, to validate if a given number is a valid BSN number of Netherlands or not.
\nNote:<\/strong> With validity, I do not mean, if this is a real existing BSN number or not, but whether that number qualifies the Elfproef<\/strong> or 11-check.<\/em> VBA Code to do 11-Check (Elfproef) for BSN<\/p>\n\n\nFunction IsValidBSN(bsn As String) As Boolean\n\n'first check if it has 9 digit\nIf VBA.Len(bsn) = 9 Then\nDim totalSum\ntotalSum = 0\n\n' Follow standard 11-check algorithm till the\n' second last digit of the 9 digit number\nFor i = 9 To 2 Step -1\ntotalSum = totalSum + CInt(VBA.Mid(bsn, 10 - i, 1)) * i\nNext\n\n' Weighted multiplication factor for\n' the last digit is (-1)\ntotalSum = totalSum + (CInt(VBA.Mid(bsn, 10 - i, 1))) * (-1)\n\n'11-Check true if divisible by 11\nIf (totalSum Mod 11) = 0 Then IsValidBSN = True Else IsValidBSN = False\n\nElse\nIsValidBSN = False ' Not a valid BSN, if length is &amp;amp;amp;lt;&amp;amp;amp;gt; 9 Digits\nEnd If\nEnd Function\n\n<\/code><\/pre>\n
What is the use of this function ?<\/h3>\n
How to use this function\u00a0?<\/h3>\n
\n