|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Set d = CreateObject("scripting.dictionary")
arr = Sheets("明细").UsedRange
crr = Array(1, 7, 4, 8, 7, 9, 8, 10, 10, 11, 12, 12, 13, 13, 14, 14)
Application.ScreenUpdating = False
Sheets("套打格式").Select
For j = 2 To UBound(arr)
d(arr(j, 1)) = d(arr(j, 1)) & "#" & j
Next
For Each k In d.keys
brr = Split(d(k), "#")
clear_pic
Call addpic(k)
x = Val(brr(1))
[n2] = k
[n3] = arr(x, 2)
[c5] = arr(x, 3)
[b6] = "地址电话:" & arr(x, 4)
[k5] = "公司名称:" & arr(x, 5)
[k6] = "地址电话:" & arr(x, 6)
cont_clear
For j = 1 To UBound(brr)
r = (j - 1) Mod 30 + 8
x = Val(brr(j))
For i = 0 To UBound(crr) Step 2
Cells(r, crr(i)) = arr(x, crr(i + 1))
Next i
If j Mod 30 = 0 Or j = UBound(brr) Then
If r < 37 Then
Rows(r + 1 & ":" & 37).EntireRow.Hidden = True
End If
[a1:n41].PrintOut
cont_clear
End If
Next j
Next k
Application.ScreenUpdating = True
End Sub
Sub add_cont(arr, brr, j, k)
[n2] = k
x = Val(brr(j))
[c5] = arr(x, 3)
End Sub
Sub cont_clear()
[a8:n37].ClearContents
[a8:n37].EntireRow.Hidden = False
End Sub
Sub clear_pic()
For Each shp In ActiveSheet.Shapes
shp.Delete
Next shp
End Sub
Sub addpic(k)
For Each shp In Sheets("LOGO").Shapes
yy = shp.TopLeftCell.Offset(0, -1).Value
If yy = k Then
shp.Copy
ActiveSheet.Paste
With Selection
.Top = [b2].Top
.Left = [b2].Left
.Width = [b2].Width
.Height = [b2:b3].Height
End With
[a4].Select
Exit For
End If
Next shp
End Sub |
|