View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
AA2e72E AA2e72E is offline
external usenet poster
 
Posts: 400
Default VBA to identify last digit in integer

The solution to your specific problem has been identified already.

This is an interesting problem. The number of digits in the integer part of
any number is given by:

int(1+log(YourNumber)/log(10))

where YourNumber can be an integer or float. Say YourNumber is 1236.45, the
last digit is:

Debug.Print mid(1236.45,int(1+log(1236.45)/log(10)),1)

This can be extended; say, you wanted the last but one digit, the position is:

int(1+log(YourNumber)/log(10)) -1

etc..