又一个Excel VBA 404错误

我希望这个脚本检查列A上的单元格,如果它们中存在URL链接的话,那么执行一些剪切粘贴操作。

string#5返回错误404,请帮助解决这个问题!

Sub xxxxxx() Worksheets("1 (2)").Activate For i = 1 To 2200 Range("A" & i).Select If (cell.Range("A1").Hyperlinks.Count >= 1) Then ActiveCell.Offset(1, 0).Range("A1").Select Selection.Cut ActiveCell.Offset(-1, 2).Range("A1").Select ActiveSheet.Paste End If Next i End Sub 

每@Siddharth Rout 发布关于不使用Activate/Select ,我已经重写你的代码下面。 每次都不需要检查循环内部的超链接,因为它总是检查单元格A1

 Sub xxxxxx() Dim ws As Worksheet Set ws = Worksheets("1 (2)") Dim LastRow As Long LastRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row If (ws.Range("A1").Hyperlinks.Count > 0) Then For i = 2 To LastRow Range("A" & i).Offset(-1, 2).Value = Range("A" & i).Value Range("A" & i).Clear Next i End If End Sub