1

我正在尝试将 excel 电子表格中的所有超链接拉到一个新的工作表中。我希望 A 列显示超链接中的文本,B 列显示超链接地址。

我已经编写了下面的代码,并且所有 B 列都可以正常工作,但是 A 列中的值并没有全部出现,并且它们与 B 列中的超链接地址不匹配。我做错了什么?

提前致谢

Sub extract_links()
    Dim hyp As Hyperlink
    Dim ReadCols As Long
    Dim ReadWriteRow As Long
    ReadWriteRow = 1
    ReadCols = 6

ActiveWorkbook.Sheets(2).Range("a:b").Clear

For c = 1 To ReadCols
    For Each hyp In ActiveWorkbook.Sheets(1).Columns(c).Hyperlinks
        ActiveWorkbook.Sheets(2).Range("a" & ReadWriteRow).Value = ActiveWorkbook.Sheets(1).Cells(ReadWriteRow, c).Value
        ActiveWorkbook.Sheets(2).Range("b" & ReadWriteRow).Value = hyp.Address
        ReadWriteRow = ReadWriteRow + 1
    Next
Next c
End Sub
4

1 回答 1

2

这次你需要改变这个:

ActiveWorkbook.Sheets(2).Range("a" & ReadWriteRow).Value = ActiveWorkbook.Sheets(1).Cells(ReadWriteRow, c).Value

进入这个:

ActiveWorkbook.Sheets(2).Range("a" & ReadWriteRow).Value = hyp.Range.Value
于 2013-04-12T09:34:54.357 回答