我正在开发一个wee宏来输出文件作为prn,它将用作其他软件的输入。我已经使一切正常工作,唯一的问题是其他软件要求所有整数都用小数点打印。
使用excel 2007 btw
即如果单元格值为0,则应将其打印为“0”。不是空白。同样,如果值为8,则应打印为“8”。这不是大多数值的问题,因为绝大多数都像123.45765等。
代码告诉我它期待a)在第4行的.NumberFormat(“”0。“”)小数点之后
Windows("bdf_generator").Activate
With Worksheets(2).Range("E2:H9592").FormatConditions _
.Add(xlCellValue, xlBetween, "=0", "=9")
FormatConditions(1).NumberFormat=(""0."")
With Selection.FormatConditions(1).StopIfTrue = False
End With
End With
答案 0 :(得分:0)
在您的情况下,由于围绕FormatConditions(1).NumberFormat=(""0."")
的两个双引号(""
),行0.
不正确。
另请注意,FormatConditions(1).NumberFormat = "0."
应添加Selection.
,否则会在运行时抛出错误。
试试这个,因为我相信它更清晰(你得到intellisense):
Windows("bdf_generator").Activate
Dim r As Excel.Range
Set r = Worksheets(2).Range("E2:H9592")
Dim fc As Excel.FormatCondition
Set fc = r.FormatConditions.Add(xlCellValue, xlBetween, "=0", "=9")
fc.NumberFormat = "0."
fc.StopIfTrue = False