VBA错误1004号码转换

时间:2014-07-29 15:53:21

标签: excel vba excel-vba

在编码方面我是一个菜鸟...所以我有一个相当简单的代码,将原始数据作为文本格式转换为数字。代码一直有效,直到我从原始数据表切换到"个人KPI"因此当我在单独的kpi表上并运行宏时,我得到了运行时错误。

Sub AccountRecon()
    Range("Table_ACCTDATA[[ARP Check Project, prep & formatting spreadsheets Volume]:[Review / Approve GL Reconciliations Minutes]]").Select
    With Selection
        Selection.NumberFormat = "0.0"
        .Value = .Value
    End With
End Sub

1 个答案:

答案 0 :(得分:0)

键入

With Something

这意味着Something位于with .. end with的每一行之前。

修正错误会产生:

Sub AccountRecon()
    Range("Table_ACCTDATA[[ARP Check Project, prep & formatting spreadsheets Volume]:[Review / Approve GL Reconciliations Minutes]]").Select
    With Selection
        .NumberFormat = "0.0" 'Removed "Selection"
        .Value = .Value
    End With
End Sub