Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to use if statement for range steps?

If i want : X<66 then Y=2000 and if 66<X<100 then Y=3200 and 100<X<120 then
Y=4000 so on....... for X---- range (66,400), how to program it?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default how to use if statement for range steps?

Hi Mansoor,

One way would be using a case statement similar to below. Obviously
the feasability of this depends on just how many intervals you want to
program on the way to 66,400. Note that I dim'd y as an integer, so it
will die if you try to make it 66,400.
If you have too many steps for this method, you could maybe try to
fina a mathematical pattern and build a formula? Hard to say without
seeing all your intervals.

Sub CaseDemo()
Dim x As Integer, y As Integer

x = InputBox("Please enter a number for x:")

Select Case x

Case Is < 66
y = 2000

Case 66 To 100
y = 3200

Case 101 To 120
y = 4000

Case Else
y = 5000

End Select

MsgBox "Seeing as you chose " & x & ", y is now: " & y

End Sub

Cheers,
Ivan.

On Apr 1, 11:16*pm, Mansoor wrote:
If i want : X<66 then Y=2000 and if 66<X<100 then Y=3200 and 100<X<120 then
Y=4000 so on....... for X---- range (66,400), how to program it?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default how to use if statement for range steps?

Case Is < 66
y = 2000

Case Is <= 100
y = 3200

Case Is <= 120
y = 4000

Case Else
y = 5000

End Select

"Mansoor" wrote:

If i want : X<66 then Y=2000 and if 66<X<100 then Y=3200 and 100<X<120 then
Y=4000 so on....... for X---- range (66,400), how to program it?

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
ADO connection Steps NickHK Excel Programming 0 January 22nd 07 03:15 AM
Jumping five steps Arne Hegefors Excel Discussion (Misc queries) 7 August 3rd 06 04:24 PM
steps to eM URL? [email protected] Excel Discussion (Misc queries) 1 March 5th 06 08:02 PM
Baby steps oberon.black[_10_] Excel Programming 4 September 5th 05 07:43 AM
Automating Add-In Steps Mokey Excel Programming 0 June 2nd 04 08:53 PM


All times are GMT +1. The time now is 03:03 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"