Giáo án link (giaoanlink) chia sẻ đến các bạn project Google sheet App Script Copy and paste value from One Spreadsheet to Other spreadsheet. Trong project này chúng ta sẽ thực hiện việc copy giá trị của vùng dữ liệu của Spreadsheet này đến paste vào sheet của Spreadsheet khác. Việc thực thi lệnh có thể thông qua Menu custom hoặc các bạn tạo các triger đáp ứng nhu cầu.
Xem thêm các bài học excel ứng dụng khác:
- Appscript Webapp | Kéo thả các Items theo 2 chiều Dọc – Ngang, Ứng dụng sắp xếp chu trình công việc
- GOOGLE SHEET WEBAPP TRA CỨU 34 TỈNH THÀNH VIỆT NAM MỚI NHẤT (SÁP NHẬP 2025)
- Quản Lý Tài Chính Cá Nhân Hiệu Quả Với Web App Google Apps Script
- Google sheet, apps script, webapp “Bé Vui Phép Nhân” – Công Cụ Luyện Toán Trực Quan Cho Học Sinh Tiểu Học
- Google sheet webapp Bé Vui Học Toán – Ứng dụng Luyện Phép Chia Trực Quan Cho Học Sinh Lớp 3
- Googlesheet appscript – Hệ Thống Đăng Ký Hồ Sơ Trực Tuyến (Online Registration Portal)
- [Share Code] Biến Google Sheet thành Web App Tra Cứu Dự Án & Tài Liệu (Miễn Phí Hosting)
- Hệ Thống Quản Lý Phòng Game “Cloud-Native” với Google Apps Script
- Hệ Thống Điều Phối & Quản Lý Đội Xe Thông Minh (Web App)
- Biến Google Sheets thành Dashboard “Viễn Tưởng” phong cách Cyberpunk
Mã apps scrip trong project:
function onOpen(){
let ui = SpreadsheetApp.getUi();
ui.createMenu('Custom Menu')
.addItem('Copy to other spreadsheet','runsies')
.addToUi();
}
function runsies() {
importRange(
"1NlK7e8m8HHRxG6noCH0SrlEWA33uO9OBypSAW4ULuaM", //Source Spreadsheet ID
"Source!A1:D", // Source Range
"1Gr90_SuotOFZNQTzs5VyNHPKop3ajpkrAMEf0Ncp7sA", // Target Spreadsheet ID
"Target!B2" // Target Begin Range
);
};
/**
* sourceID - ID of Source Spreadsheet
* sourceRange - Contain Sheet tab and Range of data
* targetID - ID of Target Spreadsheet
* targetRangeStart - cell address to start pasting the data area into targetsheet
*/
function importRange(sourceID, sourceRange, targetID, targetRangeStart){
// Get the source range values
const sourceSS = SpreadsheetApp.openById(sourceID);
const sourceRng = sourceSS.getRange(sourceRange)
const sourceVals = sourceRng.getValues();
// Get the target sheet and cell location.
const targetSS = SpreadsheetApp.openById(targetID);
const targetStartRange = targetSS.getRange(targetRangeStart);
const targetSheet = targetStartRange.getSheet();
// Clear previous entries.
targetSheet.clear();
// Get the full data range to paste from start range.
const targetRange = targetSheet.getRange(
targetStartRange.getRow(),
targetStartRange.getColumn(),
sourceVals.length,
sourceVals[0].length
);
// Paste in the values.
targetRange.setValues(sourceVals);
SpreadsheetApp.flush();
};
