0

I have a spreadsheet with a variable number of pictures (icons) in each cell (from 1 to 5), each picture with its own hyperlink. For each cell I need to identify how many pictures there are in it, and then fill in next to the cell, the HyperLink names/addresses.

The most important part I need to solve is how to identify and access all the pictures in any given cell. Getting the hyperlink address should be easy then.


I could turn the problem on its head if it would make it easier to solve and loop through every picture and return its location - if that is possible.

4

1 回答 1

2

假设您将为形状所在的活动表运行此宏...

假设TopLeft corner形状也是形状单元格位置的参考点......

以下子例程应该为您提供完整的解决方案或进一步调整的良好开端。

Sub qSolution()

    Dim SHP As Shape
    Dim rowSHP As Long
    Dim colSHP As Long

    For Each SHP In ActiveSheet.Shapes
        rowSHP = SHP.TopLeftCell.Row
        colSHP = SHP.TopLeftCell.Column

        If Cells(rowSHP, Columns.Count).End(xlToLeft) <= colSHP Then
            Cells(rowSHP, colSHP + 1) = SHP.Hyperlink.Address
        Else
            Cells(rowSHP, Columns.Count).End(xlToLeft).Offset(0, 1) = _
                                        SHP.Hyperlink.Address
        End If
    Next

End Sub
于 2013-09-08T21:58:17.967 回答