a loop code for a macro

Could you please help me write a loop code for this sequence?

 I copy the table Y1:AT4 (containing information from the table A2:X8

I insert the information of consecutive rows:

Range(“A4:V4”).Select

Range(“A5:V5”).Select

Range(“A6:V6”).Select

Until the first empty row.

And I copy a value and paste it in the new table,

 

Thank you

 

here is the code :

Range(“Y1:AT4”).Select

    Selection.Copy

    Range(“Y6”).Select

    ActiveSheet.Paste

    Range(“A4:V4”).Select

    Application.CutCopyMode = False

    Selection.Copy

    Range(“Y8”).Select

    ActiveSheet.Paste

    Range(“AT9”).Select

    Application.CutCopyMode = False

    Application.CutCopyMode = False

    ActiveCell.FormulaR1C1 = “=R[-5]C[-22]”

Range(“Y1:AT4”).Select

    Selection.Copy

    Range(“Y11”).Select

    ActiveSheet.Paste

    Range(“A5:V5”).Select

    Application.CutCopyMode = False

    Selection.Copy

    Range(“Y13”).Select

    ActiveSheet.Paste

    Range(“AT14”).Select

    Application.CutCopyMode = False

    Application.CutCopyMode = False

    ActiveCell.FormulaR1C1 = “=R[-9]C[-22]”

Range(“Y1:AT4”).Select

    Selection.Copy

    ActiveWindow.SmallScroll Down:=2

    Range(“Y16”).Select

    ActiveSheet.Paste

    Range(“A6:V6”).Select

    Application.CutCopyMode = False

    Selection.Copy

    ActiveWindow.SmallScroll Down:=3

    Range(“Y18”).Select

    ActiveSheet.Paste

    Range(“AT19”).Select

    Application.CutCopyMode = False

    Application.CutCopyMode = False

    ActiveCell.FormulaR1C1 = “=R[-13]C[-22]”

    Range(“AT20”).Select

 

    ActiveWindow.SmallScroll Down:=-12

By: altina

Leave a Reply

Your email address will not be published. Required fields are marked *