We have a shared worksheet and I’ve ben using the top section of this code to automatically change text entered by users (in select columns) to uppercase. Historically, I’ve only had to do this on one page on the worksheet. Recently we had to add a second page to the sheet. Very similar funcionality and layout, but it does have to exist on a new tab. I made a stab at duplicating my code to the new sheet, but the code only works on the original page (PDI), not the new one (Premium_PDI). Is there a simple way to get this code to work on both sheets?
Thanks
function onEdit(e) {
// Forces column not listed below in the notCols variable to update to all CAPS when edited - The header row is also excluded
var as = e.source.getActiveSheet(),
sheet = 'PDI'
notCols = [1, 8, 9, 14, 16, 17, 19, 20, 21, 28]
if (as.getName() !== sheet || notCols.indexOf(e.range.columnStart) > -1 || e.range.rowStart < 2) return;
e.range.setValue(e.value.toUpperCase());
// Forces column not listed below in the notCols variable to update to all CAPS when edited - The header row is also excluded
var as = e.source.getActiveSheet(),
sheet = 'Premium_PDI'
notCols = [1, 8, 9, 14, 16, 17, 19, 20, 21, 28]
if (as.getName() !== sheet || notCols.indexOf(e.range.columnStart) > -1 || e.range.rowStart < 2) return;
e.range.setValue(e.value.toUpperCase());
}
I’ve entered content on the original page in lowercase and it still updates it to uppercase. When entering lower case text on the new tab, nothing happens to it.
Mark Sheffield is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.