Referencing: Google Apps Script for Multiple Find and Replace in Google Sheets
I'd like to use this same code for my purposes but only within 1 column... Any advice on how to limit this script to only one column? The reason is that when I run this to change Department Names in Column J, it works perfectly, except it also changes the 'Data Type' in my Date (Columns L and M) to include timezones, and that messes up other Sheets referencing those dates... Thanks!
var values = sheet.getDataRange().getValues();
.getDataRange()
pulls data from ALL the columns. You need something likevar values = sheet.getRange(1,10,rows).getValues();
to limit the data to just Column J (column 10). Use/adapt the "trick" described here by Mogsdad to get the last row for column J, which will give you the "rows" value. Then when you've finished, you use something like sheet.getRange(1,10,rows).setValues(values); – Tedinozfunction replaceInSheet(sheet, to_replace, replace_with) { //get the current data range values as an array var values = **sheet.getDataRange()**.getValues();
withfunction replaceInSheet(sheet, to_replace, replace_with) { //get the current data range values as an array var values = **sheet.getRange('J:J')**.getValues();
– Corey Pomkoski