Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I search for a string of numeric digits within a text stri | Excel Worksheet Functions | |||
Reading Only Numeric Value of Cell | Excel Discussion (Misc queries) | |||
sumproduct - reading a variable value | Excel Discussion (Misc queries) | |||
Reading Data from another workbook... depending on variable in a cell? | Excel Discussion (Misc queries) | |||
Function in XL or in VBA for XL that pulls numeric digits from a t | Excel Discussion (Misc queries) |