Partage
  • Partager sur Facebook
  • Partager sur Twitter

Copy - Paste value from one tab to another

    26 juin 2023 à 15:10:30

    Hi,

    My issuse is the following : I would like you to write a google script. This script would allow to automate the following operation. In the tab Interview Tracker, when the value 7 - Offered is selected in the column Status (Column G), the value being on the same line of the column Role (column B) should be copied and pasted in the last row of the tab Offer Tracker in the column Role (column C). I would like rela time results. I can also tell you that The Interview Tracker Tab is composed of columns from A to J. The Offer tracker tab is composed of columns from A to G.


    I generated the following code but this does not work. Coud you please help me? Many thanks in advance.

    function onEdit(e) {

      var interviewTrackerSheet = e.source.getSheetByName("Interview Tracker");

      var offerTrackerSheet = e.source.getSheetByName("Offer Tracker");

      var editedRange = e.range;

      var editedSheet = editedRange.getSheet();

      if (editedSheet.getName() === "Interview Tracker" && editedRange.getColumn() === 7) {

        var editedRow = editedRange.getRow();

        var status = editedRange.getValue();

        if (status === "7 - Offered") {

          var role = interviewTrackerSheet.getRange(editedRow, 2).getValue(); // Column B

          var lastRow = offerTrackerSheet.getLastRow();

          offerTrackerSheet.getRange(lastRow + 1, 3).setValue(role); // Column C

        }

      }

    }

    -
    Edité par FélixMuzellec 26 juin 2023 à 15:12:00

    • Partager sur Facebook
    • Partager sur Twitter
      26 juin 2023 à 16:49:50

      Bonjour,

      Le message qui suit est une réponse automatique activée par un membre de l'équipe de modération. Les réponses automatiques leur permettent d'éviter d'avoir à répéter de nombreuses fois la même chose, ce qui leur fait gagner du temps et leur permet de s'occuper des sujets qui méritent plus d'attention.
      Nous sommes néanmoins ouverts et si vous avez une question ou une remarque, n'hésitez pas à contacter la personne en question par Message Privé.

      Pour plus d'informations, nous vous invitons à lire les règles générales du forum

      Merci de colorer votre code à l'aide du bouton Code

      Les forums d'Openclassrooms disposent d'une fonctionnalité permettant de colorer et mettre en forme les codes source afin de les rendre plus lisibles et faciles à manipuler par les intervenants. Pour cela, il faut utiliser le bouton Code de l'éditeur, choisir un des langages proposés et coller votre code dans la zone prévue. Si vous utilisez l'éditeur de messages en mode Markdown, il faut utiliser les balises <pre class="brush: jscript;">Votre code ici</pre>.

      Merci de modifier votre message d'origine en fonction.

      Liens conseillés

      • Partager sur Facebook
      • Partager sur Twitter
        5 juillet 2023 à 14:39:51

        The code you provided looks mostly correct, but there are a few adjustments that need to be made. Here's the modified version of the code that should work for your requirements:

        javascript<button class="flex ml-auto gap-2" style="border-width: 0px; border-style: solid; border-color: #d9d9e3; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; font-family: inherit; font-size: 12px; font-weight: inherit; line-height: inherit; margin: 0px 0px 0px auto; padding: 0px; appearance: button; background-image: none; cursor: pointer; display: flex; gap: 0.5rem;">Copy code</button>
        function onEdit(e) { var interviewTrackerSheet = e.source.getSheetByName("Interview Tracker"); var offerTrackerSheet = e.source.getSheetByName("Offer Tracker"); var editedRange = e.range; var editedSheet = editedRange.getSheet(); if (editedSheet.getName() === "Interview Tracker" && editedRange.getColumn() === 7) { var editedRow = editedRange.getRow(); var status = editedRange.getValue(); if (status === "7 - Offered") { var role = interviewTrackerSheet.getRange(editedRow, 2).getValue(); // Column B var lastRow = offerTrackerSheet.getLastRow(); offerTrackerSheet.getRange(lastRow + 1, 3).setValue(role); // Column C } } }

        Please make sure to follow these steps to set up the script correctly:

        1. Open your Google Sheets document.
        2. Click on "Extensions" in the menu.
        3. Select "Apps Script."
        4. Replace the default empty function in the script editor with the modified code provided.
        5. Save the script (Ctrl+S or Command+S).
        6. Close the script editor.

        Now, whenever you select the value "7 - Offered" in column G of the "Interview Tracker" sheet, the corresponding role from column B will be copied and pasted into the last row of the "Offer Tracker" sheet's column C.

        Remember that the script will execute in real-time as you make edits in the "Interview Tracker" sheet. Also, make sure to double-check the sheet names ("Interview Tracker" and "Offer Tracker") to ensure they match your actual sheet names.

        • Partager sur Facebook
        • Partager sur Twitter

        Copy - Paste value from one tab to another

        × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
        × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
        • Editeur
        • Markdown