TigraRed
New Member
- Joined
- Mar 24, 2021
- Messages
- 2
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- Mobile
- Web
Hello, Need help with my VBA code.
I need to write a script for this kind of task:
1. If on main sheet tick box is true I need the row to be copied on Completed sheet. Here is that part of script:
2. If the tick box is unmarked (false) I need that row to be removed from the Complited sheet.
} else if(s.getName() == "Complited" && r.getColumn() == 2 && r.getValue() == false) {
what next?
3. is it possible to make synced tickboxes between two sheets? E.g. If I am removing the tick from the Complited sheet the row should be deleted from the complited, also the tick should be removed also from the Main sheet row?
p.s. pardon for my English((
I need to write a script for this kind of task:
1. If on main sheet tick box is true I need the row to be copied on Completed sheet. Here is that part of script:
VBA Code:
function onEdit(event) {
// assumes source data in sheet named Main
// target sheet of move to named Complited
// getColumn with check-boxes is currently set to column 2 or B
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "Main" && r.getColumn() == 2 && r.getValue() == true) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Complited");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
2. If the tick box is unmarked (false) I need that row to be removed from the Complited sheet.
} else if(s.getName() == "Complited" && r.getColumn() == 2 && r.getValue() == false) {
what next?
3. is it possible to make synced tickboxes between two sheets? E.g. If I am removing the tick from the Complited sheet the row should be deleted from the complited, also the tick should be removed also from the Main sheet row?
p.s. pardon for my English((