Macro that runs entered value through "low" and "high" range

  • Thread starter Thread starter Vika.F
  • Start date Start date
V

Vika.F

Is there a way to write a macro that can take the entered value from th
cells A2-A10 and run it through the "low" and "high" range an
automatically enter the correct codes to cells B2-B10 in the dat
sheet.

code low high
1 0 5
2 6 10
3 11 15
4 16 20
5 21 25
6 16 30
7 31 35
8 36 40
9 41 45
10 46 50
11 51 55

For Example:
A B
7 2
3 1
53 11
42 9
32 7
53 11
14 3
28 6
5 1

Thank you very much for any hel
 
The easy way is to use the Low value and Code columns only, say A1 to
A10 has 0,6,11,16,21,26,31,36,41,46 and column B contains the relevant
code, and assuming that your data started in A20, the vlookup would be

=VLOOKUP(A20,$A$1:$B$10,2,TRUE)

which can be formula-dragged down the B column from B20 onwards.

Hope this helps.
 
Vika,

No macro necessary, just a function.

Assuming the low-high table is in K1:L11, then just put this formula in B1

=MATCH(A1,$K$1:$K$11,1)

and copy down

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Can you re-phrase the question. What are the correct code and how do you
determine these from the high low values ?
 
I need an If Then statement that will take entered value from A1:A10 and
compares it through range:
code low high
1 0 5
2 6 10
3 11 15
4 16 20
5 21 25
6 16 30
7 31 35
8 36 40
9 41 45
10 46 50
11 51 55
And then assigns correct code to cell B1:B10. For example if the
entered value in cell A1 is 5, it will automatically enter code 1 to
cell B1.
The If Then statement has take value from A1:A2 and assign code to
B1:B10.

Thank you
 
Bob,

I tried your function and it works great! I spent so much time writin
a long VB code for each cell :eek: But your function makes it s
simple. Thank you so much!!! :)

Thank you to everyone who replie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top