自动将所有工作表中的所有文本更改为大写,但不更改整个Google电子表格中的数字 [英] Change automatically all texts in all sheets to UPPERCASE but not the numbers in the entire Google spreadsheet
问题描述
我有一个电子表格,其中包含约10-12张纸,几个用户每天在添加数据.日期与数字,文本和日期混合在一起.因此,我希望所有插入的数据都自动转换为大写而不是数字,因为所有包含日期的单元格都转换为大号长整数,因此我必须再次格式化它们以具有正确的格式.
I have a spreadsheet with about 10-12 sheets that several users adding data daily. The dates are mixed with numbers, texts and dates. So, I want all the inserted data to convert automatically to UPPERCASE but not the numbers since all cells that containing dates into big long numbers and I have to format them again to have the proper format.
我不想使用Google UPPERCASE()函数.我需要一个脚本来在电子表格的所有工作表中插入任何数据时自动执行此操作.
I don't want to use Google UPPERCASE() function. I need a script to do this automatically upon any data insertion in all sheets of the spreadsheet.
当前,我正在使用以下脚本,该脚本可以正常工作,但不幸的是,它破坏了日期单元格...
Currently I am using the following script which works fine but unfortunately, it breaks the dates cells...
function onEdit(e) {
if (typeof e.value != 'object') {
e.range.setValue(e.value.toUpperCase());
}
}
关于如何使上面的脚本跳过数字和日期格式的单元格的任何想法?
Any ideas on how can I make the above script to skip number and date formatted cells?
推荐答案
这应该有效:
function onEdit(e) {
if (Object.prototype.toString.call(e.range.getValue()) !== "[object Date]" ) {
e.range.setValue(e.value.toUpperCase());
}
}
这篇关于自动将所有工作表中的所有文本更改为大写,但不更改整个Google电子表格中的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!