請教版主及各位大大們,如何使用autofilter 連同照片也copy至目的地
- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 5# cmo140497
直接複製- Option Explicit
- Sub Ex()
- Dim mytbl As Range, myQry As Range, P As Pictures, I As Integer
- Application.ScreenUpdating = False
- With Sheets("工作表1")
- .Activate
- .[a1].CurrentRegion.ClearContents
- .Range("J1", .[J1].End(xlToRight)).EntireColumn.Clear '清除舊有資料 (Clear 無法刪除圖片)
- Set P = .Pictures '圖片集合
- For I = P.Count To 1 Step -1
- If Intersect(.Range(P(I).TopLeftCell.Address), .[F:F]) Is Nothing Then '圖片位置不在 F欄
- P(I).Delete '圖片 刪除
- End If
- Next
- Set mytbl = .[F:I]
- Set myQry = .[a1]
- mytbl.Columns(4).AdvancedFilter xlFilterCopy, copytorange:=myQry, unique:=True
- Set myQry = myQry.CurrentRegion
- For I = 2 To myQry.Rows.Count
- With mytbl
- .AutoFilter 4, myQry.Rows(I)
- .SpecialCells(xlCellTypeVisible).Copy
- .Parent.Cells(1, .Parent.Columns.Count).End(xlToLeft).Offset(, 1).Select
- .Parent.Paste
- 'ActiveSheet.Paste
- End With
- Next
- End With
- mytbl.AutoFilter
- myQry.Select
- Application.ScreenUpdating = True
- End Sub
複製代碼 |
|
|
|
|
|
|
|