String and number manipulation

  • Thread starter Graham Whitehead
  • Start date
G

Graham Whitehead

Hi, I have written some code which in turn write some other code. However,
I am evaluating cells for heading and numbers, once found each number
indicates a particular variable for the new code. the problem I having is
that in 90% of the cases the numbers are simply 5 digits long and can easily
be stored as a normal variable. I am having problems however, in the other
10% of cases where there are two or three of these numbers which are
seprated by a '/'. To make life easier these numbers are always going to be
5 digits long. Can anyone help me to split these number up. My suspician
is that I am going to have to hold the value as a string - take the parts of
the string that corrrespond to the first, middle, or last 5 characters and
then cast this number back into an integer or Long varaible. Does this
process sound correct to anyone - or is there another way I have not thought
about?
 
K

KellTainer

I would really suggest you start with a clean set of data, that is all
data does not even contain the / character before you start processing.


Step 1: Use the worksheet function Substitute which allows you to
remove the / character in any variable by specifying that "/" is to be
replaced with "".
Step 2: Determine the number of 5 digits numbers within a number. You
could do this in various ways, best by using the LEN function which
returns the numebr of characters. Then, run loop and an approriate
substring function such as MID to extract the various numbers in the
line to process them.

Thats what I would do. I bet the others would have better ideas haha.
 
Top