gpt写的vba小程序,备份一下
Sub MoveData()
Dim ws As Worksheet
Dim sourceRange As Range
Dim destCell As Range
Dim i As Long
Dim numRows As Long
' 修改 Sheet1 为您要操作的工作表名称
Set ws = ThisWorkbook.Sheets("Sheet3")
' 设置源数据区域
Set sourceRange = ws.Range("L3:CT6")
' 设置起始目标单元格
Set destCell = ws.Range("K1")
' 获取源数据区域的行数
numRows = sourceRange.Rows.Count
' 循环遍历源数据区域的每一列,并将其逐一粘贴到目标单元格的相应列中
For i = 1 To sourceRange.Columns.Count
sourceRange.Columns(i).Copy
destCell.Offset((i - 1) * numRows, 0).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Next i
' 清除剪贴板内容
Application.CutCopyMode = False
End Sub