-3

Good morning all,

Can someone help me by converting this simple VBA code to Excel Script code? What the script does is it selects and entire row from the active cell and pastes it on the first row to the Template sheet.

Sub Copy()
    ActiveCell.EntireRow.Select
    Selection.Copy
    Sheets("Template").Select
    Range("A1").Select
    ActiveSheet.Paste
    Range("A1").Select
End Sub
BigBen
  • 46,229
  • 7
  • 24
  • 40
Franco
  • 1

1 Answers1

1

Instead of all the copying and pasting, why not simply use this piece of code (obviously you need to run this while having a worksheet open, different than the "Template" one):

Worksheets("Template").Range("1:1").Value = ActiveSheet.Range("1:1").Value

More information on this can be found in this other StackOverflow post.

Dominique
  • 16,450
  • 15
  • 56
  • 112
  • It needs work on a shared Excel file online. I can't use VBA code. – Franco Aug 18 '22 at 12:03
  • @Franco: I know, but I have reduced your VBA macro into a oneliner, which might just make it easier to convert to an Office script. – Dominique Aug 18 '22 at 12:06