View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] TFTAJLLYMXZP@spammotel.com is offline
external usenet poster
 
Posts: 5
Default How best to parse string lists of numbers

Hi,

I have a data source that will be providing string values made up of
individual 1,2, or 3-digit numbers separated by spaces, ranges of
numbers indicated by a dash, or a mixture of both. There are no
repeat or overlapping values, and the numbers may range from 1 to 100.

For example, the string might look like this

"1 6-9 11 16-19 21 26-29"

The goal is to count how many of these numbers fall into one of ten
ranges of numbers, i.e. 1-10, 11-20, ... 91-100, get a lookup value
based on the range, and multiply that lookup value by the count of
numbers within the range.

My first thought was to parse the string into a single-dimension array
holding the individual numbers so I can later loop through the array
in order to get the lookup value, but would appreciate any suggestions
for making this more efficient.

Thanks very much,

Terry