PC Review


Reply
Thread Tools Rate Thread

Convert decimal digit to integer

 
 
Howard31
Guest
Posts: n/a
 
      10th Mar 2010
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

 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      10th Mar 2010
Give this a try...

=MOD(1000*A1,10)

--
Rick (MVP - Excel)


"Howard31" <(E-Mail Removed)> wrote in message
news:3E2DB8EB-643A-4D72-9A70-(E-Mail Removed)...
> 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
>


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      10th Mar 2010
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" <(E-Mail Removed)> wrote in message
news:OHRDw7$(E-Mail Removed)...
> Give this a try...
>
> =MOD(1000*A1,10)
>
> --
> Rick (MVP - Excel)
>
>
> "Howard31" <(E-Mail Removed)> wrote in message
> news:3E2DB8EB-643A-4D72-9A70-(E-Mail Removed)...
>> 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
>>

>


 
Reply With Quote
 
Robert Crandal
Guest
Posts: n/a
 
      10th Mar 2010
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" <(E-Mail Removed)> wrote in message
news:3E2DB8EB-643A-4D72-9A70-(E-Mail Removed)...
> 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
>


 
Reply With Quote
 
Robert Crandal
Guest
Posts: n/a
 
      10th Mar 2010
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" <(E-Mail Removed)> wrote in message
news:UiJln.39570$(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
extract decimal and convert to integer Mike H Microsoft Excel Misc 9 1st Oct 2009 09:17 AM
Convert integer to decimal ? =?Utf-8?B?dHZpbg==?= Microsoft Dot NET 1 15th Nov 2007 01:52 PM
Need to convert integer MM into decimal inches =?Utf-8?B?THVtcHk=?= Microsoft Access VBA Modules 6 16th Feb 2007 04:47 PM
Re: convert an 18 digit decimal to a HEX value Tim Ferguson Microsoft Access VBA Modules 0 6th Jan 2007 03:51 PM
Re: convert an 18 digit decimal to a HEX value Graham R Seach Microsoft Access VBA Modules 0 6th Jan 2007 11:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:34 PM.