SQL that copies and pastes data in a database that changes

  • Good Morning,

    I have programmed a SQL coding that copy "z" data under the "a" data but the number "a" rows can change (It finishes row number 16 in my example below but it can finish row number 25)

    I have added below the coding that I had programed

    Can you change my coding in order to include the change that I want to carry out ?

     

    function azerty() {

    var spreadsheet = SpreadsheetApp.getActive();

    spreadsheet.getRange('L5').activate();

    var currentCell = spreadsheet.getCurrentCell();

    spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.NEXT).activate();

    currentCell.activateAsCurrentCell();

    currentCell = spreadsheet.getCurrentCell();

    spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).activate();

    currentCell.activateAsCurrentCell();

    spreadsheet.getRange('D11').activate();

    spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();

    spreadsheet.getRange('L5:Q10').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);

    };

    Capture d’écran 2022-06-18 à 17.28.59

    Thanks for your help

  • Hello and welcome to the forum. As your question relates to spreadsheets (Google Sheets?) rather than SQL Server, which is the subject of this forum, this may not be the best place to submit it.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • hello, but the coding related to the script used in the spreadsheet is SQL

  • there is no SQL code on your post - only something that looks like VBA.

    so do go post on a VBA or Google Sheets forum where there are bound to be people that know how to work with it.

    Posting here is likely not going to get you anywhere.

  • so how can I do to delete this thread ?

  • It can't be deleted.  No worries there, though.  It can actually help others if they end up with a similar question.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply