Loop through cells and run function

S

staeri

How can I loop through rows 14 to 33 and set the value in the A cell
returned by this function for each rows:

Range("A14").Value = CalculateScore(B14, C14, D14)

Regards,

S
 
C

Carim

Hi,

Is it what you are looking for ?

For i = 14 to 33
Range("A & i &").Value = CalculateScore(B & i, C & i, D & i)
Next i


HTH
Cheers
Carim
 
G

Guest

Range("A & i &") should be Range("A" & i)

Also, I think you need to know how the arguments for CalculateScore are
declared, strings or ranges? (and possibly variants - but the actual code in
CalculateScore should show how the arguments s/b passed).

If declared as a range, I think you'll need to use
For i = 14 to 33
Range("A" & i).Value = CalculateScore(Range("B" & i), Range("C" & i),
Range("D" & i))
Next i

If the arguments are declared as a string, then just
For i = 14 to 33
Range("A" & i).Value = CalculateScore("B" & i, "C" & i, "D" & i)
Next i

If the OP actually wants the formula in the cell then
For i = 14 to 33
Range("A" & i).Formula = "=CalculateScore(B" & i & ", C" & i & ", D" & i &
")"
Next i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top