to make this code simpler

Something like this:

Sub Macro1()
  Dim Sh1 As WorkSheet, Sh2 As WorkSheet
  Set Sh1 = Sheets("Sheet1")
  Set Sh2 = Sheets("ALB1")

  Dim R As Long
  For R = 2 to 127
    Sh1.Range("D" & R & ":E" & R).Copy Sh2.Range("C" & R - 1)
  Next R
End Sub

Or even better:

Sheets("ALB1").Range("C1:D126") = "=Sheet1!D2"

Assigning a formula that works on the first cell of a range to the whole range is equivalent to typing the formula on the first cell and copying it right and down.

Browse More Popular Posts

Leave a Comment