// Get the input collection DataTable dt = CollectionIn; // Loop through each row in the input collection for (int i = 0; i < CollectionIn.Rows.Count; i++) { // Get the values of the two columns string UniqueIDValue = CollectionIn.Rows[i]["Unique ID"].ToString(); string PDFInvoiceNumberValue = CollectionIn.Rows[i]["PDF Invoice Number"].ToString(); // Check if the value is a duplicate for (int j = i + 1; j < CollectionIn.Rows.Count; j++) { if (UniqueIDValue == CollectionIn.Rows[j]["Unique ID"].ToString() && PDFInvoiceNumberValue == CollectionIn.Rows[j]["PDF Invoice Number"].ToString()) { CollectionIn.Rows[i]["Unique ID"] = UniqueIDValue + (char)('A' + j - i - 1); CollectionIn.Rows[i]["PDF Invoice Number"] = PDFInvoiceNumberValue + (char)('A' + j - i - 1); CollectionIn.Rows[j]["Unique ID"] = UniqueIDValue + (char)('A' + j - i); CollectionIn.Rows[j]["PDF Invoice Number"] = PDFInvoiceNumberValue + (char)('A' + j - i); } } } Result = dt;