Dé Domhnaigh, Márta 26, 2023
  2 Freagraí
  Cuairteanna 5.5K
Bhí Kutools tar éis scarbhileog a dhéanamh dúinn in Excel chun iontráil dhúbailte seoladh ríomhphoist a sheachaint. Ach tá an scarbhileog seo caillte againn. Mar sin is í mo cheist an féidir an macra céanna seo a dhéanamh chun oibriú ar Google Sheets?
1 bliain ó shin
·
#3465
Haigh,

Is oth liom a rá leat nach n-oibreoidh na macraí in Excel ar Google Sheets. Beidh ort iad a athchruthú in Google Sheets.

Amanda
1 bliain ó shin
·
#3491
Bhí Kutools tar éis scarbhileog a dhéanamh dúinn in Excel chun iontráil dhúbailte seoladh ríomhphoist a sheachaint. Ach tá an scarbhileog seo caillte againn. Mar sin is í mo cheist an féidir an macra céanna seo a dhéanamh chun oibriú ar Google Sheets?


Bain triail as an VBA seo sna Google Sheets.



function checkDuplicates() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
var emailCol = 2; // Replace 2 with the column number of the email column

var emails = {};
var duplicates = [];

// Loop through the data and check for duplicates
for (var i = 1; i < data.length; i++) {
var email = data[i][emailCol];

if (email && email !== "" && emails[email]) {
// Duplicate found
duplicates.push(i + 1); // Add row number to duplicates array
} else {
// Add email to hash table
emails[email] = true;
}
}

if (duplicates.length > 0) {
// Display error message
var message = "Duplicate email(s) found on row(s): " + duplicates.join(", ");
SpreadsheetApp.getUi().alert(message);
}
}


  • Page:
  • 1
Níl aon fhreagraí déanta don phost seo go fóill.