vendredi 27 février 2015

Excel vba how to repeat an if then else condition on rows

I want to repeat my 'if then else' condition on the 30 rows that follow. This is my code (I am new to this).



Dim score As Range, result As Double
If Range("A2") = "2a" Then
Range("C2") = 20

Else
If Range("A2") = "3c" Then
Range("C2") = 23


So at the moment when I enter 2a / 3c in cell A2, the number 20 / 23 comes up in cell C2. I would like the same thing to happen in row 3, 4, 5 ... 30. When I enter 2a / 3c in cell A5, the number 20 / 23 comes up in cell C5. Is it possible with a loop or another type of code? Or will I have to copy this over and over for each row?


Any help is really appreciated. Thanks!


Aucun commentaire:

Enregistrer un commentaire