简体   繁体   中英

Between a range of values in excel 2007

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM