Sub 貼櫃號()
Dim MySht As Worksheet, dSht As Worksheet, y&
Set MySht = Sheets("出貨後")
Set dSht = Sheets("出貨明細")
With dSht
MySht.Range("C2:C10000").Clear '清除原有資料
dSht.AutoFilterMode = False '解除篩選模式
y = dSht.Range("B65536").End(xlUp).Row
If y < 2 Then MsgBox "※來源表〔B欄〕無資料! ", 0 + 16: Exit Sub
'↑先解除篩選,再檢測資料尾列列號,若篩選中,檢測列號會有誤差
If WorksheetFunction.CountIf(dSht.Range("A2:A" & y), "1") = 0 Then
MsgBox "※來源表〔A欄〕無〔1〕篩選值! ", 0 + 16: Exit Sub
End If
Sub PlayMsgbox()
Arr = Array(1, 2, 3, 4)
Brr = Array(16, 32, 48, 64)
For A = 0 To UBound(Arr): For B = 0 To UBound(Brr)
n = n + 1
MsgBox "Test-" & n, Arr(A) + Brr(B)
Next: Next
End Sub
也許下面的程式你比較看得懂,兩者是一樣的
Sub PlayMsgbox2()
n = n + 1: MsgBox "Test-" & n, 1 + 16
n = n + 1: MsgBox "Test-" & n, 2 + 16
n = n + 1: MsgBox "Test-" & n, 3 + 16
n = n + 1: MsgBox "Test-" & n, 4 + 16
n = n + 1: MsgBox "Test-" & n, 1 + 32
n = n + 1: MsgBox "Test-" & n, 2 + 32
n = n + 1: MsgBox "Test-" & n, 3 + 32
n = n + 1: MsgBox "Test-" & n, 4 + 32
n = n + 1: MsgBox "Test-" & n, 1 + 48
n = n + 1: MsgBox "Test-" & n, 2 + 48
n = n + 1: MsgBox "Test-" & n, 3 + 48
n = n + 1: MsgBox "Test-" & n, 4 + 48
n = n + 1: MsgBox "Test-" & n, 1 + 64
n = n + 1: MsgBox "Test-" & n, 2 + 64
n = n + 1: MsgBox "Test-" & n, 3 + 64
n = n + 1: MsgBox "Test-" & n, 4 + 64
End Sub