|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下,,,,
Sub test()
Dim wb As Workbook, sht As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("开票信息")
Set sh = wb.Sheets("发票基本信息")
Set sh1 = wb.Sheets("发票明细信息")
drr = sh1.[p1].CurrentRegion
arr = sht.[a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
ReDim brr(1 To 10000, 1 To 100)
ReDim crr(1 To 10000, 1 To 100)
For i = 2 To UBound(arr)
s = arr(i, 1)
If Not d.exists(s) Then
n = n + 1
d(s) = n
End If
m = d(s)
brr(m, 1) = m
brr(m, 2) = "普通发票"
brr(m, 4) = "是"
brr(m, 6) = arr(i, 3)
brr(m, 99) = brr(m, 99) + arr(i, 5)
brr(m, 100) = brr(m, 100) + arr(i, 6)
brr(m, 98) = brr(m, 98) + arr(i, 8)
brr(m, 16) = "贸易方式:一般贸易" & Chr(10) & "币别: 美元" _
& Chr(10) & "原币金额:" & brr(m, 100) & Chr(10) & "汇率:" _
& arr(i, 7) & Chr(10) & "报关编号:" & arr(i, 2) & Chr(10) & _
"订单编号:" & arr(i, 1)
crr(m, 1) = m
crr(m, 2) = arr(i, 4)
crr(m, 3) = "'" & Application.VLookup(arr(i, 4), drr, 2, 0)
crr(m, 5) = "盒"
crr(m, 6) = brr(m, 99)
crr(m, 8) = brr(m, 98)
crr(m, 9) = 0
Next
sh.[a1].CurrentRegion.Offset(3).ClearContents
sh1.[a1].CurrentRegion.Offset(3).ClearContents
sh.[a4].Resize(n, 29) = brr
sh1.[a4].Resize(n, 13) = crr
Beep
End Sub
|
|