Repeat code over 300 rows

P

Patrick Simonds

How can I alter this code so that if performs the function not just on row 2
but all the way down through row 300. I Am sure I could repeat the code for
each of the 300 rows but I bet there is a better way.

Private Sub Worksheet_Calculate()
Me.Range("A2").Value = Me.Range("D2")
End Sub
 
T

Tim Williams

for i=2 to 300
me.cells(i,1).value=me.cells(i,4).value
next i

though it's not clear from your post whether A3 should equal D2 or D3....


Tim
 
P

Patrick Simonds

Sorry

Me.Range("A2").Value = Me.Range("D2")
A3 D3
A4 A5
A6 A6

All the way down to row 300
 
P

Peter T

Hi Patrick,

Me.Range("A2:A301").Value = Me.Range("D2:D301").Value

The Me qualifier assumes code is in a Worksheet module.

Regards,
Peter T
 

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