View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default How to check the decimal number of each cells vaue in the column

right(COL.VALUE,1) = "9"

OR
VAL(right(COL.VALUE,1)) = 9

Right returns a string so you either have to compare to a string or convert
the string to a number.


"tlee" wrote:

Hi all,

As refer to my pervious post, I would like to use Macro VBA to check the
last digit (1 to 9) of the
cell value automatically?

My code as below: (may be it is complicated coding)

For Each Col In Range("A2:A9999")

If Col.Value < "" Then
If Col.Value 10 And Col.Value <= 9999 Then
Ans = Col.Value Mod 10
If Ans < 0 Then
Col.Value = Col.Value * 10
Else
Col.Value = Col.Value
End If
End If
End If

Next Col

e.g.
Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
Cell A2 = 201, 202, ........., 209 then it will be multiply by 10


However, how can I check with the data which is decimal number too, such
that 3.9 , 33.9 ......................... convert to 390,
3390...............................?

Thanks
tlee