|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("成品")
- sch = .Range("f1")
- End With
- With Worksheets("数据库")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:k" & r)
- End With
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- m = 0
- For i = 1 To UBound(arr)
- If arr(i, 4) = sch Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- If m = 0 Then
- MsgBox "没有该试场数据!"
- Exit Sub
- End If
- With Worksheets("成品")
- .Range("i1") = arr(1, 5)
- .Range("l1") = m
- For Each aa In .Shapes
- If aa.Type = 11 Then
- aa.Delete
- End If
- Next
- .Range("c3:c41,f3:f41,i3:i41,l3:l41").ClearContents
- x = 3
- y = 1
- For i = 1 To m
- .Cells(x, y + 2) = brr(i, 6)
- .Cells(x + 1, y + 2) = brr(i, 3)
- .Cells(x + 2, y + 2) = brr(i, 8)
- .Cells(x + 3, y + 2) = brr(i, 7)
- FilPath = ThisWorkbook.Path & "\照片" & brr(i, 2) & ".jpg"
- If Dir(FilPath) <> "" Then
- .Pictures.Insert(FilPath).Select
- Set rng = .Cells(x, y).Resize(4, 1)
- With Selection
- .ShapeRange.LockAspectRatio = msoFalse
- .Top = rng.Top + 1
- .Left = rng.Left + 1
- .Width = rng.Width - 1
- .Height = rng.Height - 1
- End With
- Else
- .Cells(x, y) = "没有照片"
- End If
- If y Mod 2 = 1 Then
- x = x + 5
- If x > 38 Then
- x = 38
- y = y + 3
- End If
- Else
- x = x - 5
- If x < 3 Then
- x = 3
- y = y + 3
- End If
- End If
- Next
- End With
- End Sub
复制代码 |
|