一个VBA的问题
我写了一个宏是将前几格所有的数串起来放在一个格子的程序,可是由于帐号太长结果串起来后显示的是科学记数法,希望各位大大帮忙解决
代码如下:
rivate Sub 属性汇总_Click()
j = 1
While Len(Trim(Sheet2.Cells(1, j))) > 0
j = j + 1
Wend
i = 1
While Len(Trim(Sheet2.Cells(i, 1))) > 0
For j1 = 1 To j - 1
If Sheet2.Cells(i, j1).NumberFormatLocal = "yyyy-m-d " Or Sheet2.Cells(i, j1).NumberFormatLocal = "yyyy-mm-dd " Then
Sheet2.Cells(i, j) = Sheet2.Cells(i, j) + CStr(Month(Sheet2.Cells(i, j1))) + "/ " + CStr(Day(Sheet2.Cells(i, j1))) + "/ " + CStr(Year(Sheet2.Cells(i, j1))) + "| "
Else
Sheet2.Cells(i, j) =Sheet2.Cells(i, j) + CStr(Sheet2.Cells(i, j1)) + "| "
End If
Next
i = i + 1
Wend
End Sub
[解决办法]
将目标单元格格式设为文本。如:ActiveCell.NumberFormatLocal = "@ "
[解决办法]
给你一个范例:
A1= " ' "&B1&C1&D1
看看结果
[解决办法]
cells(x,y).NumberFormatLocal = "0 " 应该没什么问题了,呵呵