展开全部
Sub 转换格式()
'假设原始表为sheet1,写入到 sheet2,第一,二行为表头,这里从第三行开始写
Sheets("sheet1").Select
j = 3 '表二的写入行
For i = 2 To ActiveSheet.UsedRange.Item(ActiveSheet.UsedRange.Count).Row
Select Case i Mod 3
Case 2:
Sheets("sheet2").Cells(j, 1).Value = Cells(i, 1).Value
Sheets("sheet2").Cells(j, 2).Value = Cells(i, 2).Value
Sheets("sheet2").Cells(j, 3).Value = Cells(i, 4).Value
Sheets("sheet2").Cells(j, 6).Value = Cells(i, 5).Value
Sheets("sheet2").Cells(j, 9).Value = Cells(i, 6).Value
Sheets("sheet2").Cells(j, 12).Value = Cells(i, 7).Value
Case 0:
Sheets("sheet2").Cells(j, 4).Value = Cells(i, 4).Value
Sheets("sheet2").Cells(j, 7).Value = Cells(i, 5).Value
Sheets("sheet2").Cells(j, 10).Value = Cells(i, 6).Value
Sheets("sheet2").Cells(j, 13).Value = Cells(i, 7).Value
Case 1:
Sheets("sheet2").Cells(j, 5).Value = Cells(i, 4).Value
Sheets("sheet2").Cells(j, 8).Value = Cells(i, 5).Value
Sheets("sheet2").Cells(j, 11).Value = Cells(i, 6).Value
Sheets("sheet2").Cells(j, 14).Value = Cells(i, 7).Value
j = j + 1
End Select
Next
Sheets("sheet2").Select
MsgBox ("转换结束")
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询