GOOGLE SHEETS: Copy last row and copy it to another sheet

belinea

New Member
Joined
Oct 20, 2022
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
I should automate so that on sheet2 it looks for the last written row, and then copies the whole row in sheet2 into row2. I have done this but I cannot paste a single line. you can help me.

const ss=SpreadsheetApp.getActive();

const sh=ss.getSheetByName('Sheet2');
const tsh=ss.getSheetByName('Sheet3');
tsh.clearContents();
const rg=sh.getRange(5,1,sh.getLastRow()-4,sh.getLastRow());
const vs=rg.getDisplayValues();
 
Last edited by a moderator:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Welcome to the Board!

What program are you trying to do this in?
It looks like it may be something other than Excel VBA.
 
Upvote 0
I'm using google sheet, sorry I didn't write it.
Yes, since this is an Excel forum, if you don't mention it, it is assumed that the question pertains to Excel.
So you should mention if you are using something other than Excel in your thread title, or original question (or both), so people know which program you are using (and you want get Excel responses that probably won't help you).

I have updated your thread title for you.
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top