View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charabeuh[_4_] Charabeuh[_4_] is offline
external usenet poster
 
Posts: 62
Default Need to check if the value in one cell is correct or not

hello,
I don'tknow where is the back of a number.
I supposed it is 6 in 6460880.

you could try this function:

Public Function Valid(Sinput As String)
Dim I, X, Xsum
For I = 1 To Len(Sinput)
X = (2 - (I Mod 2)) * Mid(Sinput, I, 1)
Xsum = Xsum + X \ 10 + (X Mod 10)
Next I
Valid = Xsum
End Function

into C2 put the formula : =valid(A2)
into D2 put the formula : =if( mod(C2,10) =)=0,"YES","NO")

if the back of the number is 0 than replace
For I = 1 To Len(Sinput)
with
For I = Len(Sinput) to 1 step -1


"RobertoB" a écrit dans le message de
groupe de discussion : ...
Hi I have a complex validation process at hand and I wonder if there is
any
way I can do this with Excel:

My data looks as follows

A1 B1 C1 D1
Code Decription Value Multiple Yes/No
6460880 Base1
6460885 Base2

I need to fill the values for columns C and D using a validation formula
for
the number on Column A

The validation for numbers goes like this - starting from the back of the
number, all the digits of the number are added together. Every other
number
is multiplied by two, and if that makes it a two digit number, each digit
is
added onto the total separately (eg 8 * 2 = 16 = 1+6 = 7). The total must
be
a multiple of 10. So, for example for the Code 6460880 we get the
following;

6460880 =
6 4 6 0 8 8 0
*1 *2 *1 *2 *1 *2 *1
=
6+ 8+ 6+0 +8 +7+0
=35 (which is not a multiple of 10 and therefore the value for C is £5 and
for D is NO)

But for the next value
6460885
=
6 4 6 0 8 8 5
*1 *2 *1 *2 *1 *2 *1
=
6+ 8+ 6+0 +8 +7+5
=40 (So the value for C is 40 and the value for D is YES as it is a
multiple
of 10) So the table will look as follows:

A1 B1 C1 D1
Code Decription Value Multiple of 10 Yes/No
6460880 Base1 35 NO
6460885 Base2 40 YES

I am using Offfice Excel 2003

Thank you for any advice you can provide