我有一个按列改变单元格格式的子程序
Sub format_columns() Application.Union(Columns("i"), Columns("k"), Columns("m")).Select Selection.NumberFormat = "0%" End Sub
格式已更改,但我必须单击或 f2 and enter 每个单元格将其更改为公式工作。
f2 and enter
我试过:
Application.EnableEvents = True
ScreenUpdating = True
如何将单元格自动更新为新格式?
在粘贴文本之前设置数字格式,或再次设置值以将其转换为数字:
Sub format_columns() For Each col In Range("I:I,K:K,M:M").Columns col.NumberFormat = "0%" col.Value = r.Value Next End Sub