Skip to main content
Support is Offline
Today is our off day. We are taking some rest and will come back stronger tomorrow
Official support hours
Monday To Friday
From 09:00 To 17:30
  Sunday, 26 March 2023
  2 Replies
  3.1K Visits
0
Votes
Undo
Kutools had made us a spreadsheet in Excel to avoid the double entry of an email address. But we have lost this spreadsheet. So my question is whether this same macro can be made to work on Google Sheets?
1 year ago
·
#3465
0
Votes
Undo
Hi,

Sorry to tell you that the macros work in Excel won't work on Google Sheets. You will have to recreate them in Google Sheets.

Amanda
11 months ago
·
#3491
0
Votes
Undo
Kutools had made us a spreadsheet in Excel to avoid the double entry of an email address. But we have lost this spreadsheet. So my question is whether this same macro can be made to work on Google Sheets?


Please try this VBA in the 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
There are no replies made for this post yet.