Solved

Google sheets: Moving rows to other sheets using trigger

Posted on 2014-12-29
5
57 Views
Last Modified: 2015-08-05
I found this edit-triggered routine from a website which works fine for inserting a comment in the edited cell. But when I modify the routine for myself the object e is not recognized at all.

Can someone do a routine for me which is activated as soon as the user enters a y in column H and moves that row (column A to column F) to the sheet whose name can be found in column G?

Here is the file

https://docs.google.com/spreadsheets/d/1yEDWuURRENO1wsG1XDoq18XjYTb7mbUKeViLe4S-1Mo/edit?usp=sharing
0
Comment
Question by:Saqib Husain, Syed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40530123
HI,

pls try ( do not forget to create the trigger )

function onEdit(event)
{
  var ss = event.source.getActiveSheet();
  var r = event.source.getActiveRange();

  if(ss.getName() == "Applications"){
    if(r.getColumn() == 8){
      if(r.getValue().toString().toLowerCase() == "y"){
        var destShName = r.offset(0, -1).getValue()
        var destSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(destShName);
        if (destSheet != null) {
          var lastRow = destSheet.getLastRow()+1;
          var rCopyFrom = ss.getRange(r.getRow(), 1, 1, 6);
          rCopyFrom.copyTo(destSheet.getRange('A'+lastRow));
          ss.deleteRow(r.getRow());
        }else{
          Browser.msgBox('Sheet name is not available!');
        }
      }
    }
  }
}

Open in new window

Regards
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 40604351
Hi, Rgonzo1971,  sorry for being away.

I had tried this at that time and it worked. In fact, I had written a routine initially and it worked. Later the event did not fire. When I tried your routine later again the event did not fire. I have not been able to spend time on this which is why my response was delayed.

I wonder what is stalling the firing of the event.
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 40610720
Cannot help further as my sheet continues to word perfectly
Sorry
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 40644413
Hi and sorry again. I need more time before testing.

You can post a reply to keep the clock ticking.
0
 
LVL 43

Author Closing Comment

by:Saqib Husain, Syed
ID: 40916144
I am off that project now and may never get to use this. So shall close this as it did work the first time.

Thanks
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of my favorite tools to use with Google Drive is the offline access. Setting up offline access for Google Drive makes it easier for users to edit and view their docs, sheets and slides without Internet connection. Follow these steps to learn how…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
By using UNIQUE function in Google Sheets, you can get around removing duplicates like in Microsoft Excel.
This Micro Tutorial will demonstrate how to use comments in Google Docs. You will learn how to create, edit, and delete a comment.

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question