|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
大家好 给我老师好
有个问题再次请教 如何根据A列合并的单元格 FOR循环时统计合并单元格的行数
谢谢!
Sub OB_OUTER_NEW()
On Error Resume Next
Dim sht As Worksheet
Set sht = Sheets("SHIPPING MARK")
Set Sht1 = Sheets("OUTER")
Sht1.Activate
Sht1.Range("A1").Select
r = Sheets("SHIPPING MARK").Cells(Rows.Count, 1).End(xlUp).Row
arr = Sheets("SHIPPING MARK").Range("A3:R" & r - 1)
For i = UBound(arr) To 1 Step -1
If arr(i, 1) <> "" Then
t = arr(i, 1)
Exit For
End If
Next i
x = InputBox(" 请输入打印起始箱号数。", , 1)
If x = "" Then Exit Sub
For i = 1 To UBound(arr)
If arr(i, 1) >= --x Then
Range("B3:B6,B8,B12:B15,B17,D3,D12,E1:E2,E10:E11") = ""
[B3] = arr(i, 5)
[B4] = arr(i, 3)
[B5] = arr(i, 7)
[B6] = arr(i, 8)
[B8] = arr(i, 12)
[E1] = arr(i, 10)
' 这个位置希望是FOR循环时根据A列合并的单元格行数 自动写入E2单元格
' 目前是 只是 6和0为判断依据,(希望根据内箱的数量自动计算 ,有时内箱数量5,有时内箱数量为6,或者没有内箱)
不知该怎么改啊 FOR 内循环 MREGEAREA.COUNT也是会出错
If arr(i, 2) <> "" Then
[E2] = 6
Else
[E2] = ""
End If
[D3] = arr(i, 1) & " / " & t
[B12] = arr(i, 5)
[B13] = arr(i, 3)
[B14] = arr(i, 7)
[B15] = arr(i, 8)
[B17] = arr(i, 12)
[E10] = arr(i, 10)
If arr(i, 2) <> "" Then
[E11] = 6
Else
[E11] = ""
End If
[D12] = arr(i, 1) & " / " & t
Application.ScreenUpdating = True
If MsgBox("点击“是”,继续打印;点击“否”,终止打印。", vbYesNo) <> vbYes Then Exit Sub
' Sht1.PrintOut copies:=1
' ActiveWindow.SelectedSheets.PrintOut copies:=1
End If
Next i
MsgBox "OUTER 打印完成"
End Sub
|
|