-1

How do I take data that populates in to different columns on one sheet and transfer them to another sheet, but in the same column? I have tried to run my code, however I am getting an error that says,

Exception: The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues.dewarData

regarding the last line of code. I have provided a portion of my code below:

const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet1 = ss.getSheetByName('Form Response Data')
const sheet2 = ss.getSheetByName('Data Overview');
let [vb] = sheet1.getDataRange().getDisplayValues().map(([a,b,c,d,e,f,au,az,ba,bb,bc,bd,be])=> 
[`${az} ${ba} ${bb} ${bc}`]);
sheet2.getRange(3,10,vb.length,vb[0].length).setValues(vb); 
1
  • Try just let vb =
    – TheWizEd
    Commented Oct 4, 2023 at 15:37

2 Answers 2

0

I would do it like this:

function myfunk01() {
  const col = 8;//set this to whatever dolumn you wish to start with
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sheet1 = ss.getSheetByName('Sheet0')
  const sheet2 = ss.getSheetByName('Sheet1');
  let vb = sheet1.getRange(2, col, sheet1.getLastRow() - 1, 6).getDisplayValues().map(([a, b, c, d]) =>
    [`${a} ${b} ${c} ${d}`]);
  sheet2.getRange(3, 10, vb.length, vb[0].length).setValues(vb)
}

This was my data:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1 COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14 COL15 COL16 COL17 COL18 COL19 COL20 COL21 COL22 COL23 COL24 COL25 COL26
2 A2 B2 C2 D2 E2 F2 G2 H2 I2 J2 K2 L2 M2 N2 O2 P2 Q2 R2 S2 T2 U2 V2 W2 X2 Y2 Z2
3 A3 B3 C3 D3 E3 F3 G3 H3 I3 J3 K3 L3 M3 N3 O3 P3 Q3 R3 S3 T3 U3 V3 W3 X3 Y3 Z3
4 A4 B4 C4 D4 E4 F4 G4 H4 I4 J4 K4 L4 M4 N4 O4 P4 Q4 R4 S4 T4 U4 V4 W4 X4 Y4 Z4
5 A5 B5 C5 D5 E5 F5 G5 H5 I5 J5 K5 L5 M5 N5 O5 P5 Q5 R5 S5 T5 U5 V5 W5 X5 Y5 Z5
6 A6 B6 C6 D6 E6 F6 G6 H6 I6 J6 K6 L6 M6 N6 O6 P6 Q6 R6 S6 T6 U6 V6 W6 X6 Y6 Z6
7 A7 B7 C7 D7 E7 F7 G7 H7 I7 J7 K7 L7 M7 N7 O7 P7 Q7 R7 S7 T7 U7 V7 W7 X7 Y7 Z7
8 A8 B8 C8 D8 E8 F8 G8 H8 I8 J8 K8 L8 M8 N8 O8 P8 Q8 R8 S8 T8 U8 V8 W8 X8 Y8 Z8
9 A9 B9 C9 D9 E9 F9 G9 H9 I9 J9 K9 L9 M9 N9 O9 P9 Q9 R9 S9 T9 U9 V9 W9 X9 Y9 Z9
10 A10 B10 C10 D10 E10 F10 G10 H10 I10 J10 K10 L10 M10 N10 O10 P10 Q10 R10 S10 T10 U10 V10 W10 X10 Y10 Z10
11 A11 B11 C11 D11 E11 F11 G11 H11 I11 J11 K11 L11 M11 N11 O11 P11 Q11 R11 S11 T11 U11 V11 W11 X11 Y11 Z11
12 A12 B12 C12 D12 E12 F12 G12 H12 I12 J12 K12 L12 M12 N12 O12 P12 Q12 R12 S12 T12 U12 V12 W12 X12 Y12 Z12
13 A13 B13 C13 D13 E13 F13 G13 H13 I13 J13 K13 L13 M13 N13 O13 P13 Q13 R13 S13 T13 U13 V13 W13 X13 Y13 Z13
14 A14 B14 C14 D14 E14 F14 G14 H14 I14 J14 K14 L14 M14 N14 O14 P14 Q14 R14 S14 T14 U14 V14 W14 X14 Y14 Z14
15 A15 B15 C15 D15 E15 F15 G15 H15 I15 J15 K15 L15 M15 N15 O15 P15 Q15 R15 S15 T15 U15 V15 W15 X15 Y15 Z15
16 A16 B16 C16 D16 E16 F16 G16 H16 I16 J16 K16 L16 M16 N16 O16 P16 Q16 R16 S16 T16 U16 V16 W16 X16 Y16 Z16
17 A17 B17 C17 D17 E17 F17 G17 H17 I17 J17 K17 L17 M17 N17 O17 P17 Q17 R17 S17 T17 U17 V17 W17 X17 Y17 Z17
18 A18 B18 C18 D18 E18 F18 G18 H18 I18 J18 K18 L18 M18 N18 O18 P18 Q18 R18 S18 T18 U18 V18 W18 X18 Y18 Z18
19 A19 B19 C19 D19 E19 F19 G19 H19 I19 J19 K19 L19 M19 N19 O19 P19 Q19 R19 S19 T19 U19 V19 W19 X19 Y19 Z19
20 A20 B20 C20 D20 E20 F20 G20 H20 I20 J20 K20 L20 M20 N20 O20 P20 Q20 R20 S20 T20 U20 V20 W20 X20 Y20 Z20
21 A21 B21 C21 D21 E21 F21 G21 H21 I21 J21 K21 L21 M21 N21 O21 P21 Q21 R21 S21 T21 U21 V21 W21 X21 Y21 Z21
22 A22 B22 C22 D22 E22 F22 G22 H22 I22 J22 K22 L22 M22 N22 O22 P22 Q22 R22 S22 T22 U22 V22 W22 X22 Y22 Z22
23 A23 B23 C23 D23 E23 F23 G23 H23 I23 J23 K23 L23 M23 N23 O23 P23 Q23 R23 S23 T23 U23 V23 W23 X23 Y23 Z23
24 A24 B24 C24 D24 E24 F24 G24 H24 I24 J24 K24 L24 M24 N24 O24 P24 Q24 R24 S24 T24 U24 V24 W24 X24 Y24 Z24
25 A25 B25 C25 D25 E25 F25 G25 H25 I25 J25 K25 L25 M25 N25 O25 P25 Q25 R25 S25 T25 U25 V25 W25 X25 Y25 Z25
26 A26 B26 C26 D26 E26 F26 G26 H26 I26 J26 K26 L26 M26 N26 O26 P26 Q26 R26 S26 T26 U26 V26 W26 X26 Y26 Z26

This was my output:

A B C D E F G H I J K
1
2
3 H2 I2 J2 K2
4 H3 I3 J3 K3
5 H4 I4 J4 K4
6 H5 I5 J5 K5
7 H6 I6 J6 K6
8 H7 I7 J7 K7
9 H8 I8 J8 K8
10 H9 I9 J9 K9
11 H10 I10 J10 K10
12 H11 I11 J11 K11
13 H12 I12 J12 K12
14 H13 I13 J13 K13
15 H14 I14 J14 K14
16 H15 I15 J15 K15
17 H16 I16 J16 K16
18 H17 I17 J17 K17
19 H18 I18 J18 K18
20 H19 I19 J19 K19
21 H20 I20 J20 K20
22 H21 I21 J21 K21
23 H22 I22 J22 K22
24 H23 I23 J23 K23
25 H24 I24 J24 K24
26 H25 I25 J25 K25
27 H26 I26 J26 K26
-1

Good afternoon, I attach the rangeList() and flat() method proposal

/**
 * Get values range list origen
 * Set values range Destination* 
 * @returns [array] array float array[0].length = 1
 */
function setValuesRangeListFlat(){
  /**
   * Get Class Spreadsheet
   * @return {class}  Methods Class Spreadsheet
   * @see Class Spreadsheet:
   * https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet
   */
  const classSpreadSheet =  SpreadsheetApp.getActive();

  /**
   * Get Class Sheet
   * @returns {class} Methods Class Sheet
   * @see Clas Sheet:
   * https://developers.google.com/apps-script/reference/spreadsheet/sheet
   */
  const clasSheetOrigin = classSpreadSheet.getSheetByName('Sheet1');

  /**
   * Get Class Sheet
   * @returns {class} Methods Class Sheet
   * @see Clas Sheet:
   * https://developers.google.com/apps-script/reference/spreadsheet/sheet
   */
  const clasSheetDestination = classSpreadSheet.getSheetByName('Sheet2');

  /**
   * Set range type A1Notation single column.
   * Not A1:C10 is A1:A10, B1,B10, C1:C10
   * @returns {array} array range A1Notations
   * @see Method getRangelist():
   * https://developers.google.com/apps-script/reference/spreadsheet/sheet#getrangelista1notations
   */
  const a1Notations = ['A:A', 'B1:B', 'E:E']
  /**
   * Get values range list
   * @returns {array} value get ranges
   * @see Method getRange():
   * https://developers.google.com/apps-script/reference/spreadsheet/range#getvalues
   */
  const arrValores = clasSheetOrigin.getRangeList(a1Notations).getRanges()
      .map(function(row){return row.getValues()})
        .flat(1); // @see https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Array/flat

  clasSheetDestination.getRange(1,1,arrValores.length,arrValores[0].length)
            .setValues(arrValores);}/* End if */

Not the answer you're looking for? Browse other questions tagged or ask your own question.