Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Reading specific digits from a numeric variable

How can I read specific digits (e.g. last five digits, or the middle five or
whatever..) from a numerical variable (A)?

The digits I read from variable A, I need to put in another numeric variable
(B).

Thanks in advance!
srdjan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Reading specific digits from a numeric variable

use MID/Left,Right The number will be coerced into a string

lngVal = 1234567890
? mid(lngVal,4,5)
45678
? left(lngVal,5)
12345
? right(lngVal,5)
67890


--
Regards,
Tom Ogilvy

"Srdjan Kovacevic" wrote in message
...
How can I read specific digits (e.g. last five digits, or the middle five

or
whatever..) from a numerical variable (A)?

The digits I read from variable A, I need to put in another numeric

variable
(B).

Thanks in advance!
srdjan




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Reading specific digits from a numeric variable

One way is to convert your number to a string first (using
CStr function), then use string functions to get your
digits (i.e., Mid(YourNumber, 3, 5)) and convert them back
to numbers.

Another way is to devide your numbers by corresponding
power of 10 and take integer part. I.e., to extract one
digit in the 3-rd position from number 1735, devide it by
mod 10^3 (x mod 10^3) to get 0.735, then multiply by 10^1
to get 7.35, and take integer (7). As you can see, power
of 3 is the starting position, and power of 1 is the
number of digits to extract. You can right a simple
function now.


-----Original Message-----
How can I read specific digits (e.g. last five digits, or

the middle five or
whatever..) from a numerical variable (A)?

The digits I read from variable A, I need to put in

another numeric variable
(B).

Thanks in advance!
srdjan


.

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
How can I search for a string of numeric digits within a text stri Eric_NY Excel Worksheet Functions 9 January 23rd 09 07:07 PM
Reading Only Numeric Value of Cell F. Lawrence Kulchar Excel Discussion (Misc queries) 5 April 9th 08 01:58 AM
sumproduct - reading a variable value redneck joe Excel Discussion (Misc queries) 3 May 24th 06 08:02 PM
Reading Data from another workbook... depending on variable in a cell? Rob Moyle Excel Discussion (Misc queries) 4 March 13th 06 04:21 PM
Function in XL or in VBA for XL that pulls numeric digits from a t Nate Oliver Excel Discussion (Misc queries) 0 December 14th 04 04:57 PM


All times are GMT +1. The time now is 03:46 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"