我有一个vba命令,它将0(我需要它)添加到与我的目的相关的特定规则。该命令将单元格转换为“文本”类型。我对取消订单的更正命令感兴趣(在某些情况下我必须回去)这是我的代码:
Sub Add_Zeros()
Selection.NumberFormat = "@"
For Each CL In Selection.Cells
Select Case Len(CL)
Case 8: CL.Value = "0" & CL.Value
Case 9: CL.Value = IIf(Left(CL.Value, 1) = 5, "0", "") & CL.Value
Case "" 'do nothing
Case Else
End Select
Next
End Sub
您是否有恢复上一个操作的代码?也许将单元格恢复为原始类型为“数字”
提前致谢 ,
如果您只想删除前导零,则可以执行以下操作:
Sub remove_Zeros()
With Selection
.NumberFormat = "General"
.Value = .Value
End With
End Sub