Hi Team i have 2 excel sheets with me
and i have input variable as “721st Judicial District Court, Travis County, Texas”
here in these 2 excel i want to replace Judicial District Court with JDC from Excel sheet
and in the same way i want to replace Texas with TX from States-abbreviations excel sheet. i want to check all the values in excel in both the sheets
here input variable value will be changed everytime. and that value should be checked in excel sheets Address.xlsx (9.1 KB) States-abbreviations.xlsx (9.3 KB)
Read Excel Sheets:
Use the ‘Excel Application Scope’ activity to read both Excel sheets into DataTable variables. Let’s call them dataTable1 for the first sheet and dataTable2 for the second sheet.
Define Input Variable:
You mentioned that the input variable value changes every time. Let’s assume you have a string variable named inputVariable that holds the value “721st Judicial District Court, Travis County, Texas” or any other value.
Perform Replacements:
Use LINQ queries to perform the replacements on both DataTables. Here’s an example LINQ query for the first DataTable (dataTable1):
dataTable1.AsEnumerable().ToList().ForEach(Sub(row)
row("Column Name") = row("Column Name").ToString().Replace("Judicial District Court", "JDC")
row("Column Name") = row("Column Name").ToString().Replace("Texas", "TX")
End Sub)
Note: Replace "Column Name" with the actual column name where you want to perform the replacements.
Similarly, for the second DataTable (dataTable2):
dataTable2.AsEnumerable().ToList().ForEach(Sub(row)
row("Column Name") = row("Column Name").ToString().Replace("Texas", "TX")
End Sub)
Write Back to Excel:
After performing the replacements, use the ‘Write Range’ activity to write the updated DataTables back to the respective Excel sheets.