I have written the following code which is basically supposed colour some boxes accordingly. Whenever i run this code, it runs the first case i.e. even when some other case
In addition to the errors noted by the other answers posted here, it is important to note the construct used for testing your condition is If with ElseIf. By using this to test your condition, you will always execute the first ElseIf condition resolving to True and skip any later conditions which may be defined.
This means you may end up with logical issues in formatting according to the appropriate conditions you intended to format.
For this reason, I would recommend using the Case statement construct as provided by @mwolfe02 in the response above along with all similar formatting conditions within the same Case statement. This would prevent various formatting situations from occurring based on what conditions had been met in a particular ordering of data.
Hope that helps.