VB code. If statement between two values

N

nappyjim

I have a worksheet where a user input a value. There can be 5 differen
fomulas based on what value the user enters. How do I make a vb scrip
to say

If the value of sheet1 cell A1 is between 1 and 5, do A1-A2.

If the value of sheet1 cell A1 is between 6 and 10, do A1+A
 
R

Ron Rosenfeld

I have a worksheet where a user input a value. There can be 5 different
fomulas based on what value the user enters. How do I make a vb script
to say

If the value of sheet1 cell A1 is between 1 and 5, do A1-A2.

If the value of sheet1 cell A1 is between 6 and 10, do A1+A2

Take a look at Help for Select Case

e.g: Select Case UserInput
Case 1 to 5
Result=A1-A2
Case 6 to 10
result = a1+a2
case else
result ="Out Of Range"
End select
 

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

Top