Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 3
Default VB code. If statement between two values

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
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,045
Default VB code. If statement between two values

On Sat, 9 Feb 2013 17:22:08 +0000, nappyjim wrote:


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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement but in code Jock Excel Programming 3 September 7th 09 12:19 PM
VBA code with and / or statement Steve Excel Programming 3 January 31st 08 11:47 PM
Why does this code remove Duplicate Values, by showing only 1, but it does NOT show Unique values for some reason ? Corey Excel Programming 4 February 23rd 07 02:00 AM
VBA code for IF statement with OR? Dave R. Excel Programming 4 June 27th 05 03:38 PM
if statement between values Qaspec Excel Worksheet Functions 2 February 21st 05 02:06 AM


All times are GMT +1. The time now is 11:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"