They are mostly used with Loops and If statements. A condition is a statement that evaluates to true or false. Sub ReadMarksDim i As Long ' Go through the marks columns For i = 2 To 11' Check if marks greater than 50 If Sheet1.Range( 'C' & i).Value 50 Then ' Print student name to the Immediate Window(Ctrl + G) Debug.Print Sheet1.Range( 'A' & i).Value & ' ' & Sheet1.Range( 'B' & i).ValueEnd If Next End SubResultsBryan SnyderJuanita MoodyDouglas BlairLeah FrankMonica BanksPlay around with this example and check the value or the sign and see how the results change.If ConditionsThe piece of code between the If and the Then keywords is called the condition. Select code and click icons to indent/outdentIf you look at any code examples on this website you will see that the code is indented.A Simple If Then ExampleThe following code prints out the names of all students with marks greater than 50 in French.
0 Comments
Leave a Reply. |