左侧VBA设置单元格值0
问题描述:
我试着像“0001”的值介绍使用VBA细胞,但所有我设置为1,没有000左侧VBA设置单元格值0
这是我的代码
Dim iRow As Long
Dim ws As Worksheet: Set ws = Worksheets(BD_PRODXSIST)
With ws
.Range("A" & iRow).Value = "0001"
End With
Set ws = Nothing
答
要插入文本使用撇号。
.Range("A" & iRow).Value = "'0001"
或者你也可以在输入号码后更改格式:
.Range("A" & iRow).Value = "1"
.Range("B" & iRow).NumberFormat = "0000"