|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
不太会写VBA,献丑了
Sub splitrows()
Dim sr, sc, cr, dr, dc
dr = 2
For sr = 2 To Sheet1.Range("a1").End(xlDown).Row
sc = Sheet1.Range("a" & sr).End(xlToRight).Column
cr = Int((sc - 1) / 2)
For i = 1 To cr
Sheet2.Cells(dr, 1).Value = Sheet1.Cells(sr, 1).Value
Sheet2.Cells(dr, 2).Value = Sheet1.Cells(sr, 2).Value
Sheet2.Cells(dr, 3).Value = Sheet1.Cells(sr, 1 + 2 * i).Value
Sheet2.Cells(dr, 4).Value = Sheet1.Cells(sr, 2 + 2 * i).Value
dr = dr + 1
Next i
Next sr
End Sub |
评分
-
1
查看全部评分
-
|