1

I am stuck here in printing permutation of two or more characters horizontally along that row in which the characters are. Is it possible? Because I searched it all over and only found vertical output along the column.

I have to make permutations of different people from different community and create their user names. The below is what I get after entering my formula

enter image description here

Here is the code:

function permuteEmails(a,b,c) {
  var ssheet = SpreadsheetApp.getActive();
  var sheet = ssheet.getSheetByName('Person Details');
  var array = [];

  var aVal = sheet.getRange(a).getDisplayValue();
  var bVal = sheet.getRange(b).getDisplayValue();
  var cVal = sheet.getRange(c).getDisplayValue();

  var aVal_first = aVal.slice(0,1);
  var bVal_first = bVal.slice(0,1);

  array.push(aVal + "." + bVal + "@" + cVal);
  array.push(bVal + "." + aVal + "@" + cVal);
  array.push(aVal + "@" + cVal);
  array.push(aVal + "." + bVal_first + "@" + cVal);
  array.push(aVal + bVal_first + "@" + cVal);
  array.push(aVal_first + bVal + "@" + cVal);

  return array;
}

But I want it to look like, that after entering the details and applying the formula, all the combinations should print along the same row in which we entered the details.

  • share a copy of your sheet with an example of the desired output – user0 Jun 6 at 18:53
  • I have made the changes – RageRemix Jun 6 at 19:08
  • can you share a copy of your sheet? or add the permuteemails script you use? – user0 Jun 6 at 19:26
  • I have added the code. Please look into it. – RageRemix Jun 7 at 16:48
  • 1
    I didn't try the second formula. This is working perfectly, thank you. – RageRemix Jun 10 at 7:48
0
  • try: =TRANSPOSE(PERMUTEEMAILS("A2", "B2", "C2"))

    0

  • or use this:

    =ARRAYFORMULA(IF(LEN(C2:C), LOWER({
     A2:A&"."&B2:B&"@"&C2:C, 
     B2:B&"."&A2:A&"@"&C2:C,
     B2:B&"@"&C2:C,
     B2:B&"."&LEFT(A2:A, 1)&"@"&C2:C,
     B2:B&LEFT(A2:A, 1)&"@"&C2:C,
     LEFT(B2:B, 1)&A2:A&"@"&C2:C}), ))

    0

  • @HimanshuSharma answer updated – user0 Jun 7 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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