|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
下面数组strN中存储的是字符串(有的比较长),赋值给单元格区域时,一开始正常,后来表格“奖罚”添加的数据多了,就出现类型不匹配错误,不知道为什么,请高手指点一下迷径。代码如下,加粗处出现错误!
Sub 生成奖罚单()
Application.ScreenUpdating = False
Dim i As Integer, j As Integer, k As Integer
Dim strN(25), N(), strName()
N = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
strName = Array("检一", "检二", "电一", "电二", "原一", "原二", "水洗", "装一", "装二", "采制化", "铲车", "集控", "库房")
With Sheets("奖罚")
j = .[a65536].End(xlUp).Row
For k = 0 To 12
For i = 2 To j
If .Cells(i, 1) = strName(k) Then
N(k) = N(k) + 1
If (Len(strN(2 * k)) + Len(.Cells(i, 7)) + 7) < 1024 Then
strN(2 * k) = strN(2 * k) & "【" & N(k) & "】" & .Cells(i, 7) & "。"
Else
strN(2 * k + 1) = strN(2 * k + 1) & "【" & N(k) & "】" & .Cells(i, 7) & "。"
End If
End If
Next
Next
End With
With Sheets("奖罚明细")
.Rows("3:28").Hidden = False
.Range("b3:b28") = Application.Transpose(strN) '这句调试正常,但奖罚表添加项目多的时候,有时候出现错误:类型不匹配,不知道怎么回事?
End With
Application.ScreenUpdating = True
End Sub
|
|