VBA根据他们的位置选择形状 [英] VBA select shapes based on their positions

查看:157
本文介绍了VBA根据他们的位置选择形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何选择单元格A:Shape.TopLeftCell.Row= 0 中的所有形状(数组?范围?)?

How do I select all shapes (array? range?) where the value in Cell "A:Shape.TopLeftCell.Row" = 0 ?

推荐答案

作为替代方案,您可以反转逻辑并选择如果需要,请将选择分配给shaperange:

Just as an alternative, you can reverse the logic and select as you go, then assign the selection to a shaperange if required:

Sub ShapePicker()
    Dim s As Shape
    Dim sr As ShapeRange
    Dim i As Long

    i = 1
    For Each s In ActiveSheet.Shapes
        If Cells(s.TopLeftCell.Row, "A").Value = 0 Then
            s.Select (i = 1)
            i = i + 1
        End If
    Next s
    Set sr = Selection.ShapeRange
End Sub

这篇关于VBA根据他们的位置选择形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆