Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Google sheets: Moving rows to other sheets using trigger

Posted on 2014-12-29
5
Medium Priority
?
58 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 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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 53

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

You can provide a virtual interface for remote stakeholders in a SWOT analysis through a Google Drawing template. By making real time viewing and collaboration possible, your team can build a stronger product.
Explore the encryption capabilities built into Google Apps and how these features can help you meet privacy policy and regulatory compliance, but are not a full solution. Understand and compare the most popular email encryption services for Google A…
This Micro Tutorial will demonstrate how to analyze your website's back links using a network graph powered by a fusion table.
This Micro Tutorial will demonstrate Google Calendar to monitor updates with top sites, such as Facebook, Google, Twitter, etc. with Marketing News. Each update of Google Calendar can be monitored, correlate dips and spikes in your website traffic, …

670 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