+ Reply to Thread
Results 1 to 6 of 6

Excel script to copy/paste special values for specific rows based on column criteria

  1. #1
    Registered User
    Join Date
    04-13-2017
    Location
    Mount Pleasant, WI
    MS-Off Ver
    Office 2016
    Posts
    3

    Excel script to copy/paste special values for specific rows based on column criteria

    Hello, I am attempting to write a script to "lock down" values (e.g. copy / paste special values) and eliminate the current formula. I only want this action to apply to monthly values (col. AF - AQ) that are in rows that have "Q1 FRCST", col G when our forecast is finalized. I would click the "script button" when I wanted this action to occur. I am just starting to figure out scripts. Can I do this by script or another path (VBA or even formula)? Would prefer not to do this via VMA (macro).

    I have added the Excel tab that has the information as well as snap shot of my current script.

    Thank you.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Excel script to copy/paste special values for specific rows based on column criteria

    Does this work for you?

    PHP Code: 
    function main(workbookExcelScript.Workbook) {
        
    let selSheet workbook.getActiveWorksheet();
        
    let lr selSheet.getUsedRange().getRowCount()+1;
        
    let Range1 selSheet.getRange("G1:G" lr);
        
    let vScenario Range1.getValues() as string[][];

        for (
    let i 3lri++) {
            if (
    vScenario[i][0] == "Q1 FRCST") {
                
    let TheRange "AF" + (1) + ":AQ" + (1);
                
    selSheet.getRange(TheRange).copyFrom(selSheet.getRange(TheRange), ExcelScript.RangeCopyType.valuesfalsefalse);
            }
        }


  3. #3
    Registered User
    Join Date
    04-13-2017
    Location
    Mount Pleasant, WI
    MS-Off Ver
    Office 2016
    Posts
    3

    Re: Excel script to copy/paste special values for specific rows based on column criteria

    Hello ByteMarks! I appreciate you looking into my question. No errors when running the script, unfortunately the script does not complete the task of copy/ paste special values. The formula remains in AF - AQ.

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Excel script to copy/paste special values for specific rows based on column criteria

    Hmm works for me.
    There were no formulae in AF-AQ of the the attached file, but if you put them in and then run the script, where column G is "Q1 FRCST" (rows 7,13,19,25,31)
    then the formulae are replaced with values.

  5. #5
    Registered User
    Join Date
    04-13-2017
    Location
    Mount Pleasant, WI
    MS-Off Ver
    Office 2016
    Posts
    3

    Re: Excel script to copy/paste special values for specific rows based on column criteria

    I got it work now. I started a new script rather than editing my old script. Much appreciated!! Thank you!

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Excel script to copy/paste special values for specific rows based on column criteria

    Great news!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy /Paste column on specific time using excel script
    By aimandoo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-30-2023, 04:57 AM
  2. Replies: 7
    Last Post: 07-29-2021, 11:11 AM
  3. Replies: 2
    Last Post: 03-18-2015, 05:31 AM
  4. [SOLVED] VBA - Copy and Paste data based on two criteria to specific start row and column
    By ndgo10 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2014, 09:15 AM
  5. Macro to paste special all values in a spreadsheet with specific criteria
    By Don0401 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-30-2011, 11:39 AM
  6. Copy - Paste Special.Values (with extra function) VBA Script needed!
    By Kevin2110 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2011, 10:07 AM
  7. Copy / Paste Special Values Script
    By TomTom_BV in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-26-2009, 09:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1