假设包含数据的工作表称为Sheet1,因为您没有提供很多有用的信息。
Sub TransposeData()
Dim ws1 As Worksheet
Set ws1 = Worksheets("Sheet1")
Dim DataRange As Range
Dim DataCell As Range
Dim x As Integer
Dim y As Integer
Dim LastRow As Long
x = 0
y = 0
With ws1
LastRow = .Cells.Find(What:="*", After:=.Range("A1"), LookAt:=xlPart, LookIn:=xlFormulas, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
End With
Set DataRange = ws1.Range("A1:A" & LastRow)
For Each DataCell In DataRange
If DataCell.Value <> "" Then
ws1.Range("C2").Offset(y, x).Value = DataCell.Value
x = x + 1
If x = 4 Then
x = 0
y = y + 1
End If
End If
Next DataCell
End Sub
这样就可以了。为动态操作编辑。