将单元格格式化为数字类型"百分比"

时间:2015-11-02 22:07:50

标签: excel format applescript

我正在尝试将Microsoft Excel中的范围" C3:C8" 格式化为数字格式百分比。以下代码不起作用,我不确定为什么。运行脚本后,范围" C3:C8" 仍然格式化为" General"

我正在使用Excel for Max 2011和Applescript Editor Version 2.7

set formatRange to range "C3:C8" of sheet "Sheet1"

set number format of (formatRange of (sheet "Sheet1" of active workbook)) to "Percentage"

2 个答案:

答案 0 :(得分:1)

tell application "Microsoft Excel"
front document activate
set formatRange to range "C3:C8" of sheet "Sheet1" of active workbook
set number format of formatRange to "###.00%"
end tell

单元格值1将转换为100.00%,单元格值0.02将变为2.00% 当然,你可以改变字符串" ###。00%"用" ###。0%"如果你只想要1个十进制数字。

答案 1 :(得分:0)

找出解决方案......或至少暂时解决方法

将范围“C3:C8”的值设置为“0%” - 这会自动将格式设置为百分比

将范围“C3:C8”的值设置为“” - 现在将每个单元格的值设置为空白,但将格式保留为百分比

相关问题