Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Convert decimal digit to integer

Hi All,

I have the value 1.0020 in a cell, I want to assign the second right decimal
(2) to an integer variable, how do I do that?

Any help will be very much appreciated

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Convert decimal digit to integer

Give this a try...

=MOD(1000*A1,10)

--
Rick (MVP - Excel)


"Howard31" wrote in message
...
Hi All,

I have the value 1.0020 in a cell, I want to assign the second right
decimal
(2) to an integer variable, how do I do that?

Any help will be very much appreciated


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Convert decimal digit to integer

Whoops.... what I posted is not what you asked for. Your actual question is
a little strange. When dealing with floating point numbers, one rarely needs
to know a digit measure in from the end; rather, one usually wants to know
the digit so-many-positions in from the decimal point. The reason is because
"true numbers" do not have trailing zeroes, only string representations of
numbers can hold trailing zeroes. So I'm not really sure you want what you
asked for. Anyway, consider these...

Second digit from the end of a String value
========================================
Variable = Mid(StringNumber, Len(StringNumber) - 1, 1)

Third digit in from decimal point
========================================
Variable = Int(1000 * Number) Mod 10

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Give this a try...

=MOD(1000*A1,10)

--
Rick (MVP - Excel)


"Howard31" wrote in message
...
Hi All,

I have the value 1.0020 in a cell, I want to assign the second right
decimal
(2) to an integer variable, how do I do that?

Any help will be very much appreciated



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Convert decimal digit to integer

How's this for a crazy solution:

Dim x as Integer

x = Left(Right(Sheet1.Range("A1").Text, 2), 1)

I think that returns what u want??


"Howard31" wrote in message
...
Hi All,

I have the value 1.0020 in a cell, I want to assign the second right
decimal
(2) to an integer variable, how do I do that?

Any help will be very much appreciated


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Convert decimal digit to integer

Oh, my mistake..... I was assuming that your decimal
digit was stored in Cell A1. So, if your decimial number
is stored in A1, then that code will work and it will save
the value in variable x!



"Robert Crandal" wrote in message
...
How's this for a crazy solution:

Dim x as Integer

x = Left(Right(Sheet1.Range("A1").Text, 2), 1)

I think that returns what u want??


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
extract decimal and convert to integer Mike H Excel Discussion (Misc queries) 9 October 1st 09 09:17 AM
integer with decimal display oldLearner57 Excel Discussion (Misc queries) 1 July 3rd 07 12:30 PM
Convert 2 digit month to 4 digit years and months BB Excel Worksheet Functions 2 September 17th 06 09:33 PM
VBA to identify last digit in integer brucemc[_8_] Excel Programming 5 May 27th 06 06:54 AM
Create number format for 4 digit integer preceded by zero Headfish Excel Worksheet Functions 6 April 14th 06 08:56 PM


All times are GMT +1. The time now is 06:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"