|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下,楼主的代码有点问题,活动单元格这里不对,不能这样来的。
- Private Sub CommandButton1_Click()
-
- Rem 删除原有图片
- Dim Shap As Shape
- For Each Shap In Shapes
- If Shap.Type = msoAutoShape Then Shap.Delete
- Next
-
- Dim Arr
- Dim i As Long
- Dim j As Long
- Dim r As Long
- Dim m As Long
- Dim H, W, L, T
- r = Cells(Rows.Count, 1).End(xlUp).Row
- Arr = Range("a1:c" & r + 1)
- Arr(r + 1, 3) = 0
- For i = 2 To r
- If Arr(i, 3) <> "" Then
- For j = i + 1 To UBound(Arr)
- If Arr(j, 3) <> "" Then m = j - 1: Exit For
- Next j
- With Range("c" & i & ":c" & m)
- .Merge
- L = .Left
- T = .Top
- W = .Width
- H = .Height
- .Select
- End With
- ActiveSheet.Shapes.AddShape(msoShapeRectangle, L, T, W, H).Select
- Selection.ShapeRange.Fill.UserPicture ActiveWorkbook.Path & "\图片目录" & Arr(i, 3) & ".jpg"
- End If
- Next i
-
- End Sub
复制代码 |
|