是否有想要在 Excel 中做到
B1 =A1
B2 =A3
B3 =A5
B4 =A7
B5 =A9
可以用這個巨集
Sub FillAndSkip()
Dim CellToCopy As Range
Dim n As Integer
Dim x As Integer
n = Val(InputBox("Increment relative references by how many cells?"))
Set CellToCopy = Selection.Cells(1)
For x = 2 To Selection.Rows.Count
' COPY the formula to a cell n cells down to update relative
' references.
CellToCopy.Copy
CellToCopy.Offset(n, 0).Range("A1").Select
ActiveSheet.Paste
' CUT and paste to the desired destination so the references don't
' change.
Application.CutCopyMode = False
Selection.Cut
CellToCopy.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
' Start from the formula just created to get the next formula.
Set CellToCopy = Selection
Next x
End Sub
沒有留言:
張貼留言