Sub A() Dim ws As Worksheet Dim srcRow As Long, destRow As Long, col As Integer Dim hyp As Hyperlink Dim lastRow As Long Set ws = ThisWorkbook.Sheets("Sheet3") lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row destRow = 1 For srcRow = 1 To lastRow Step 4 col = 1 ' 目标列的起始列偏移 ' 处理四行数据 For i = 0 To 4 If srcRow + i <= lastRow Then ' 复制值 ws.Cells(destRow, col + 2).Value = ws.Cells(srcRow + i, 1).Value ' 检查并复制超链接 If ws.Cells(srcRow + i, 1).Hyperlinks.Count > 0 Then Set hyp = ws.Cells(srcRow + i, 1).Hyperlinks(1) ws.Hyperlinks.Add Anchor:=ws.Cells(destRow, col + 2), _ Address:=hyp.Address, _ SubAddress:=hyp.SubAddress, _ TextToDisplay:=ws.Cells(srcRow + i, 1).Text End If ' 移动到下一列 col = col + 1 End If Next i destRow = destRow + 1 Next srcRow End Sub
Option Explicit Sub test() Dim i%, lastRow%, n% lastRow = Cells(Rows.Count, 1).End(3).Row n = 1 For i = 2 To lastRow Step 4 n = n + 1 Cells(i, 1).Resize(4).Copy Cells(n, 3).PasteSpecial Transpose:=True Next i End Sub