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
Solved

Google sheets: Moving rows to other sheets using trigger

Posted on 2014-12-29
5
54 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
  • 3
  • 2
5 Comments
 
LVL 50

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 50

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Last month, Google released a new update for Google Sheets. This new update offers new ways to visualize and analyze data. Use this article to learn how to take advantage of the new tools now available for charts, cells and collaboration with Google…
With voice direction tools, various map viewing styles, the ability to get directions for different means of transportation and great service, Google Maps is simply one of the best navigations app in the market.    However, over the past year, an …
By using UNIQUE function in Google Sheets, you can get around removing duplicates like in Microsoft Excel.
This Micro Tutorial demonstrates how to quickly find related content for YourTango's posts using MozBar Chrome extension.

856 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