Solved

Google sheets: Moving rows to other sheets using trigger

Posted on 2014-12-29
5
50 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 48

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 48

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Not everyone is tied to the Microsoft Office suite these days, as more free cloud-based solutions are entering the market. You might be used to creating presentations in PowerPoint, but did you know Google offers Slides  (https://www.google.com/slid…
Learn new improvements released by Google for Google Calendar. Noted in this article are simple tips and tricks that can make your everyday use of Google Calendar better.
This Micro Tutorial will demonstrate without sampling how to find out top organic landing pages. The hack gets around the standard way to find the pages in Google Analytics results in sampling for larger sites.
This Micro Tutorial will demonstrate using Google Doc how to import live data to another spreadsheet in Google Spreadsheets using the IMPORTRANGE function.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now