Free Excel VBA Course #16 - SELECT CASE Statement in Excel VBA

preview_player
Показать описание
In this video, I will show you how to use the SELECT CASE statement in Excel VBA.

Select Case is useful when you have three or more conditions that you want to check. You can also use this with two conditions (but I feel If Then Else is easier to use in those cases).

In this video, I take an example of student scores and how to assign them grades based on the scores.

#Excel #ExcelTips #ExcelTutorial
Рекомендации по теме
Комментарии
Автор

I found your channel so well educated!!! Thank you for your hard work!

nkaujhnub
Автор

Hi Sumit,
How we can run this for all rows in one go.?
Do we need to give range at start or need to c+v code for each cell ?

akashdeshmukh
Автор

Hi Sumit
can you help me
i want to know
can we count colored text in cell
if yes then plz tell
i will be very thank full

sando
Автор

Sir, how many times, can i use if condition in nextedif?

milindkumarjawalgekar
Автор

alternatively we can do this from this method where I have assigned all code in single button:

Private Sub CommandButton1_Click()
Dim i As Integer


For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
Select Case Range("B" & i).Value

Case Is < 35
Range("C" & i).Value = "Fail"
Case Else
Range("C" & i).Value = "Pass"
End Select

Next i

For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
Select Case Range("B" & i).Value

Case Is < 35 '----you can also use 0 to 34
Range("D" & i).Value = "F"

Case Is < 50
Range("D" & i).Value = "D"

Case Is < 70
Range("D" & i).Value = "C"
Case Is < 80
Range("D" & i).Value = "B"
Case Else
Range("D" & i).Value = "A"
End Select
Next i
End Sub

SachinSingh-vess