![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1ajehhYtq6fj5wSISMFCS2IiMRCseNuHh6xXpw2Ub_JNX28QF2-QDfsg-L3P0ShRzJsKzARNH9Pi4fQo017-dmX0aLLqzUzniwXY6nNg1gDjrFqWCowGtBQXA7I2Y9GiajYE5dTw5Yzs/s320/seperate_line.jpg)
Sub seperateLine()
lastr = Rows(Rows.Count).End(xlUp).Row
For r = 2 To lastr * 2
If (r Mod 2) <> 0 Then
Rows(r).Insert Shift:=xlDown
End If
Next r
End Sub
如果第一行 ( Header ) 和第一個 record 也要隔一空行的話,只需要把(line 3) r = 2 改成 r = 1
移除隔行
Sub removeLine()
Cells(1, 3).Select
lastr = Rows(Rows.Count).End(xlUp).Row
Cells(1, 1).Select
lastc = Columns(Columns.Count).End(xlToLeft).Column
r = 2
Do While r < lastr
cnt = 0
For c = 1 To lastc
If Cells(r, c) = "" Then
cnt = cnt + 1
End If
Next c
If cnt = lastc Then
Rows(r).Delete Shift:=xlUp
End If
r = r + 1
Loop
End Sub
沒有留言:
張貼留言