|
楼主 |
发表于 2016-7-3 12:06
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
红色部分显示错误。
Private Sub CommandButton3_Click()
Dim nRow%, Arr(), Brr(), Crr(), m%, n%
nRow = Range("b65536").End(xlUp).Row
If nRow = 1 Then Exit Sub
Arr = Range("a2:g" & nRow).Value
ReDim Brr(1 To nRow, 1 To 7), Crr(1 To nRow, 1 To 7)
For i = 1 To nRow - 1
For j = 1 To 7
If Arr(i, j) = "" Then Exit For
Next
If j = 8 Then
m = m + 1
For k = 1 To 7
Brr(m, k) = Arr(i, k)
Next
Else
n = n + 1
For k = 1 To 7
Crr(n, k) = Arr(i, k)
Next
End If
Next
If m > 0 Then
With Sheet2
n = .Range("a65536").End(xlUp).Row + 1
.Range("a" & n).Resize(m, 7).Value = Brr
End With
End If
Me.Range("a2:g" & nRow).Value = Crr
End Sub |
|