|
本帖最后由 魂断蓝桥 于 2020-3-26 16:18 编辑
Option Explicit
Sub a()
Dim arr, d, s$, i%, k
'Application.ScreenUpdating = False
Set d = CreateObject("Scripting.Dictionary")
arr = Sheet3.[d1].CurrentRegion
For i = 2 To UBound(arr)
s = arr(i, 1) & arr(i, 2) & arr(i, 3)
d(s) = ""
Next
Sheet1.Activate
[a2:a999] = ""
k = d.keys
[a2].Resize(d.Count, 1) = Application.Transpose(k)
Set d = Nothing
Call b
'Application.ScreenUpdating = True
End Sub
Sub b()
Dim myf, arr, i%, wb As Workbook, ran As Range, r%
Dim myw, myh, myl, myt, mysha
For Each mysha In Sheet1.Shapes
If mysha.Type = 13 Then mysha.Delete
Next
myw = [b2].Width
myh = [b2].Height
arr = [a2].CurrentRegion
myf = ActiveWorkbook.Path & "\产品表.xlsx"
Set wb = Workbooks.Open(myf)
With wb.Sheets(1)
For i = 1 To UBound(arr)
Set ran = .Range("a:a").Find(arr(i, 1), , , 1)
If Not ran Is Nothing Then
r = ran.Row
.Shapes("图片 " & r).Copy
ThisWorkbook.Sheets("图片").Activate
Cells(i + 1, 2).Select
myl = ActiveCell.Left
myt = ActiveCell.Top
ActiveSheet.Paste
With Selection.ShapeRange
.LockAspectRatio = msoFalse
.Width = myw - 5
.Height = myh - 5
.Left = myl + 2
.Top = myt + 2
End With
End If
Next
End With
wb.Close 0
End Sub |
评分
-
1
查看全部评分
-
|