office交流網--QQ交流群號

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

判斷當前單元格是否包含有圖片的判斷函數

2020-06-06 08:00:00
zstmtony
原創
7970



判斷當前單元格是否包含有圖片的判斷函數
Sub CellHasPicture()
    Dim xRg As Range
    Dim xShape As Shape
    Dim xFlag As Boolean
    On Error Resume Next
    Set xRg = Application.InputBox("Please enter the cell address:", "Excel", Selection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    xFlag = False
    For Each xShape In ActiveSheet.Shapes
        If xShape.TopLeftCell.Address = xRg.Address Then
            xFlag = True
        End If
    Next
    If xFlag Then
        MsgBox "Image exists!"
    Else
        MsgBox "Image does not exist"
    End If
End Sub

分享