>即時新聞-熱門

2008年12月25日星期四

EXCEL VBA 向下填滿自動

Sub 向下填滿()
Z = 0 ' 次數
Range("a1").Select
ActiveCell.SpecialCells(xlLastCell).Select
E = ActiveCell.Row
Range("a1").Select
For i = 1 To E ' 填滿次數
x = ActiveCell.Value
Selection.End(xlDown).Select
y = ActiveCell.Value
If x <> y Then Z = Z + 1
End If
Next
Range("a1").Select
For i = 1 To Z - 1
x = ActiveCell.Address
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
y = ActiveCell.Address
W = x & ":" & y
Range(W).Select
Selection.FillDown
Selection.End(xlDown).Select
Next
End Sub

0 评论:

 
妹咕數位學園歡迎網友們來信指教 妹咕信箱