Results 1 to 8 of 8

Copy cells from a table to another table with conditions.

Threaded View

AlexisUANL Copy cells from a table to... 01-22-2023, 11:31 PM
BadlySpelledBuoy Re: Copy cells from a table... 01-23-2023, 03:25 AM
AlexisUANL Re: Copy cells from a table... 01-23-2023, 11:17 AM
BadlySpelledBuoy Re: Copy cells from a table... 01-23-2023, 12:50 PM
AlexisUANL Re: Copy cells from a table... 01-23-2023, 01:15 PM
k1dr0ck Re: Copy cells from a table... 01-23-2023, 03:49 AM
AlexisUANL Re: Copy cells from a table... 01-23-2023, 11:16 AM
b-gonzalez Re: Copy cells from a table... 01-25-2023, 12:06 PM
  1. #8
    Registered User
    Join Date
    01-24-2023
    Location
    Los Angeles
    MS-Off Ver
    Office 365
    Posts
    1

    Re: Copy cells from a table to another table with conditions.

    You can try the script below. I show that it is working with the file you provided:

    function main(workbook: ExcelScript.Workbook) {
    let inputTbl = workbook.getTable("Table1")
    let outputTbl = workbook.getTable("Table3")

    let nameCol = inputTbl.getColumnByName("Name").getRangeBetweenHeaderAndTotal().getValues() as string[][]
    let nationCol = inputTbl.getColumnByName("Write your nacionality.").getRangeBetweenHeaderAndTotal().getValues() as string[][]
    let cityCol = inputTbl.getColumnByName("Choose you city.").getRangeBetweenHeaderAndTotal().getValues() as string[][]
    let ageCol = inputTbl.getColumnByName("Write your age.").getRangeBetweenHeaderAndTotal().getValues() as string[][]

    let inputVals = inputTbl.getRangeBetweenHeaderAndTotal().getValues() as string[][]

    let inputRowCount = inputTbl.getRangeBetweenHeaderAndTotal().getRowCount()
    let inputColCount = inputTbl.getRangeBetweenHeaderAndTotal().getColumnCount()
    let tempArr: string[][] = []

    for (let i = 0; i < inputRowCount; i++) {
    for (let j = 0; j < inputColCount; j++) {
    if (inputVals[i][j] === "Yes") {
    let finding = inputVals[i][j + 1]
    let temp: string[] = [nameCol[i][0], finding, nationCol[i][0], cityCol[i][0], ageCol[i][0]]
    tempArr.push(temp)
    }
    }
    }

    outputTbl.addRows(-1,tempArr)

    }
    Last edited by b-gonzalez; 01-25-2023 at 10:54 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need formula to count table range depending on conditions in selected table columns
    By jj2105 in forum Excel Formulas & Functions
    Replies: 29
    Last Post: 05-27-2022, 04:49 AM
  2. Macro to fill 1st table with info from 2nd table. 2nd table search with 2 conditions
    By Ribeiro.JD in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-17-2016, 02:03 PM
  3. [SOLVED] copy dynamic data from one table to another one with 2 conditions
    By sa4a in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2014, 04:41 PM
  4. Macro to copy a table and paste in another table (based on certain conditions)
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-22-2013, 01:14 PM
  5. Merging Table Cells with Text under Certain Conditions
    By verdecove in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-31-2009, 08:08 PM
  6. Moving data from a pivot table to another table based on conditions
    By MarinaDBrown in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2009, 12:11 PM
  7. [SOLVED] sum cells in table using column and row conditions
    By NEIL@NEIL1975.PLUS.COM in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-06-2006, 03:10 AM

Tags for this Thread

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