在线表AirScript脚本编辑器运行问题
根据超级黑化新路佬帮写的代码,加工测试后发现有BUG
本意是通过代码实现单元格文本倒数第三和第四的文本自动变红,结果发现部分单元格死活就是第四和第五个。
【金山文档 | WPS云文档】 12345679
https://kdocs.cn/l/cqW7YstaypXg
代码:
let row = 1;
const lastRow = Application.Cells(Application.Rows.Count, 1).End(xlUp).Row;
while (row <= lastRow) {
const cell = Application.Cells(row, 1);
const text = String(cell.Value2); // 确保转为字符串
if (text.length >= 4) {
// 修改倒数第 3 和第 4 个字符(位置 9 和 10)
Application.Cells(row, 2).Value2 = text.length
cell.Characters(text.length - 3, 2).Font.ColorIndex = 3;
}
row++;
}
@金山办公
创作者俱乐部成员