Move a row from one sheet to another when a checkbox is ticked

Kanger14

New Member
Joined
Jan 27, 2020
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hello there,

I am looking for a script that would allow me to move an entire row over to another sheet when a checkbox is ticked.

I need it moved from the sheet "Call Log" to the sheet "Test" when the value in row 13 shows as TRUE (from the checkbox)

So far what I have done is essentially set up a little IF statement in column 14, where if the checkbox is ticked in 13, it writes out the word "Vape". Then I use the following script to try and pull the data:


function onEdit() {

var sheetNameToWatch = 'Call Log';

var columnNumberToWatch = 14;

var valueToWatch = "VAPE";

var sheetNameToMoveTheRowTo = 'TEST';



var ss = SpreadsheetApp.getActiveSpreadsheet();

var sheet = SpreadsheetApp.getActiveSheet();

var range = sheet.getActiveCell();



if (sheet.getName() == sheetNameToWatch && range.getColumn() == columnNumberToWatch && range.getValue() == valueToWatch) {

var targetSheet = ss.getSheetByName(sheetNameToMoveTheRowTo);

var targetRange = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);

sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRange);

}

}


It debugs fine, but does not do what I am asking it to, so any help here is appreciated.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,216,106
Messages
6,128,863
Members
449,473
Latest member
soumyahalder4

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