Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default how do i use IF ELSE IF FUNCTION in excel to chk more condition

You use If ElseIf in the following manner:

Sub UseIfElseIf()
With Range("A1")
If .Value = 1 Then
'do something
ElseIf .Value = 2 Then
'do something else
ElseIf .Value = 3 Then
'do something else again
''
''
''
End If
End With
End Sub


However, if there are a large number of ElseIf statements, and if the only
'true' statement is in one of the last ElseIfs's you'll find there's a speed
increase by using Case Statements (they both follow the same logic) e.g.


Sub SelectCase()
Select Case Range("A1").Value
Case 1
'do something
Case 2
'do something else
Case 3
'do something else again
''
''
''
End Select
End Sub

HTH,
John
--
The major part of getting the right answer lies in asking the right
question...


"chemnks" wrote:

i want to check code no(eg. 1,2,3,4,5) in a particular cell and for related
code match i want to display a contents from other cell

Please suggest

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 function with certain condition Pran New Users to Excel 5 July 17th 09 02:48 AM
conditional: stop function under certain condition kana Excel Worksheet Functions 1 September 5th 07 03:54 PM
max function with condition shaji Excel Discussion (Misc queries) 3 July 10th 06 05:02 PM
adding part of a function on condition. foxgguy2005 Excel Worksheet Functions 4 May 26th 05 02:45 PM
IF Function with formatting condition ABDIAZ Excel Worksheet Functions 2 April 27th 05 10:20 PM


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

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

About Us

"It's about Microsoft Excel"