发新话题
打印

[VBA] 请高手帮助解决工程量计算表的二次输入问题(#value)

请高手帮助解决工程量计算表的二次输入问题(#value)

有一个工程量计算表VB如下:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.MoveAfterReturn = False
    Rem 在此处加入计算式
    Dim RowNum As Long, ColumnNum As Long
    RowNum = Target.Row
    ColumnNum = Target.Column
    If Cells(RowNum, ColumnNum) = "" Then
        Application.MoveAfterReturnDirection = xlDown
        “Application.MoveAfterReturn = True
        Exit Sub
    End If
    Cells(RowNum, ColumnNum + 1) = Evaluate(Application.WorksheetFunction.Substitute _
                (Application.WorksheetFunction.Substitute(Cells(RowNum, ColumnNum), "[", "*ISTEXT(""["), "]", "]"")"))
    Cells(RowNum, ColumnNum) = Application.WorksheetFunction.Substitute _
                    (Application.WorksheetFunction.Substitute(Cells(RowNum, ColumnNum), "*", "×"), "/", "÷")
   
    Application.MoveAfterReturn = True
    Application.MoveAfterReturnDirection = xlDown
    Cells(RowNum + 1, ColumnNum).Select
End Sub


计算表只支持一次输入,如果再次点击的话,那结果项就会变成#value了,那将是十分不雅,请高手相助,解决这个问题,谢谢

TOP

试试吧

你所说的只输入一次,是只能在EXCEL中只能赋一次值吧!  可否将你再点击的格赋为空呢? cell(x,y)="" 或=0  ,这样可否!

TOP

发新话题