打印一系列超链接

时间:2010-06-26 06:40:32

标签: excel vba

如何通过选择“A”列中的行来打印“D:E”列中的超链接文件

Sub Print_Hyperlinks()

    Dim rng     As Range
    Dim row     As Range
    Dim cell    As Range
    Dim LastRow As Long


    LastRow = Range("A2").End(xlDown) 'Print only selected rows in "A"

    Set rng = Range("D2:E" & LastRow)

    For Each row In rng.Rows
      For Each cell In row.Cells
           Selection.Hyperlinks(1).Follow   'List of Hyperlinks in Column "D"
           Selection.Hyperlinks(2).Follow   'List of Hyperlinks in Column "E"
      Next cell
    Next row

End Sub

1 个答案:

答案 0 :(得分:0)

你需要引用最后一行而不是其中的数据,即替换

LastRow =范围(“A2”)。结束(xlDown)'仅打印“A”中的选定行 同 LastRow = Range(“A2”)。End(xlDown).row'仅打印“A”中的选定行

克里斯