View Single Post
  #20   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernard Liengme[_2_] Bernard Liengme[_2_] is offline
external usenet poster
 
Posts: 563
Default Validation of UK VAT Number

Can I join this free-for-all?
Here's my contribution that I forgot to send yesterday
1) returns FALSE/TRUE
=MOD(SUMPRODUCT(VALUE(MID(SUBSTITUTE(A2,"
",""),{1;2;3;4;5;6;7},1)),{8;7;6;5;4;3;2}),97)-97=-RIGHT(A2,2)
2) returns text of choice
=IF(=MOD(SUMPRODUCT(VALUE(MID(SUBSTITUTE(A2,"
",""),{1;2;3;4;5;6;7},1)),{8;7;6;5;4;3;2}),97)-97=-RIGHT(A2,2),"Valid",
"Invalid")
best wishes
--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme


"Rob" wrote in message
...
Hi,

I want to check a number of VAT numbers using a formula, the first check
is to ensure the number is 9 digits (may need to remove spaces to ensure
clean data). The process is then to apply the below criteria which has
proved difficult for he to accomplish.

Any help will be most welcome. Thanks, Rob
1.. The first seven digits of the VAT registration number are listed
vertically.
2.. Each digit is multiplied by a number, starting with 8 and decreasing
to 2.
3.. The sum of the multiplications is calculated.
4.. 97 is subtracted from the sum as many times as is necessary to arrive
at a negative number.
5.. The negative number should be the same as the last 2 digits of the
VAT registration number if it is valid.
Example:

VAT registration number 339 0727 47

3 *8 = 24
3 *7 = 21
9 *6 = 54
0 *5 = 0
7 *4 = 28
2 *3 = 6
7 *2 = 14

Total = 147

147 - 97 = 50 - 97 = - 47

As the negative number(- 47) is the same as the last two digits of the VAT
number, the number is valid.

1.. The first seven digits of the VAT registration number are listed
vertically.
2.. Each digit is multiplied by a number, starting with 8 and decreasing
to 2.
3.. The sum of the multiplications is calculated.
4.. 97 is subtracted from the sum as many times as is necessary to arrive
at a negative number.
5.. The negative number should be the same as the last 2 digits of the
VAT registration number if it is valid.