Loop to determine number of rows range

T

transferxxx

Can anybody tell me why macro is not looping to last cell in row of
column c - pls correct my macro. Thxs

Sub Loop()

Dim i As Integer
For i = 1 To Range("A1").CurrentRegion.Rows.Count - 1
Range("C2").FormulaR1C1 = "=Average(RC[-1],RC[-2])"
Range("C2").Offset(1, 0).Select
Next i
End Sub
 
B

Bob Phillips

Sub Loop()

Dim i As Integer
i = Range("A1").CurrentRegion.Rows.Count
Range("C2").Resize(i).FormulaR1C1 = "=Average(RC[-1],RC[-2])"
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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