此代码有什么问题?运行时,它返回好的值,但格式不正确-值存储为文本
For i = 2 To nrow
For j = 2 To ncol
With Worksheets(j - 1)
Set rang= .Range("A:F")
End With
Dim wart As Variant
wart = Application.VLookup(Cells(i, 1), rang, 6, False)
Cells(i, j) = wart
If IsError(Cells(i, j)) Then Cells(i, j) = 0
Cells(i, j) = Format(Cells(i, j), "Percent")
当疣的数据类型更改为Double时-出现“类型不匹配”错误
答案 0 :(得分:1)
格式化错误!
Format(Cells(i, j), "Percent")
似乎不正确
将Cells(i, j) = Format(Cells(i, j), "Percent")
替换为Cells(i, j).NumberFormat= "0.00%"
还要确保您将值设置为Cells(i, j).Value = wart
。