views:

42

answers:

1

I have a column of numbers in Excel 2007, for example:

19
35
29
62

What i want to do is: If the value is between 0-20 replace the value with 0.1
If the value is between 20-25 replace it with 0.2

The bin sizes are not going to be the same (0-20, 20-25, 30-50, 50-60, 65+) etc, and the values to replace the numbers with are not necessarily going to be sequential.

Is there a formula for this? Could a macro work? It would take forever with a find and replace.

Thanks

+1  A: 

Simplest: a table on a sheet, two columns, one for lower bounds of bands and one for respective values:

 0  0.1
20  0.2
25  0.3
30  0.4
50  0.5
60  0.6

Then the formula: =VLOOKUP(value_to_replace,table_address,2,TRUE)

Make sure bounds are sorted or the trick will not work. Replacement values do not have to be sorted.

GSerg
Nice. Much cleaner and simpler than the VBA macro I was working on using SELECT CASE.
JohnK813
Hi, where do i put the formula? I tried `=VLOOKUP(i1:i1000,a1:b3,2,TRUE)` in a blank cell, where i is my column of data. And it returned 0.3... thanks
joec
never mind - my mistake. thanks
joec