Solved

Google sheets: Moving rows to other sheets using trigger

Posted on 2014-12-29
5
51 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 49

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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Learn about cloud computing and its benefits for small business owners.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial  demonstrates whether your site uses one subdomain or multiple subdomains, how to create full URLs from Google Analytics content reports. This procedure is called concatenation and can also be done with the CONCATENTATE function.…
This Micro Tutorial will demonstrate how to analyze your website's back links using a network graph powered by a fusion table.

862 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

23 Experts available now in Live!

Get 1:1 Help Now