- 帖子
- 2035
- 主題
- 24
- 精華
- 0
- 積分
- 2031
- 點名
- 0
- 作業系統
- Win7
- 軟體版本
- Office2010
- 閱讀權限
- 100
- 性別
- 男
- 註冊時間
- 2012-3-22
- 最後登錄
- 2024-2-1
|
回復 22# slip
試試看!- Sub duplicate_Click()
- Dim nextRows As Single
-
- With Sheets("Sheet1")
- nextRows = .Range("A" & Rows.Count).End(xlUp).Row + 1
- .Range("A" & nextRows & ":AH" & .UsedRange.Rows.Count).ClearContents
-
- .Range("A" & nextRows & ":E" & nextRows).Value = Sheets("Sheet1").[A2:E2].Value ' A-E
- .Range("I" & nextRows & ":AH" & nextRows).Value = Sheets("Sheet1").[I2:AH2].Value ' I-AH
- .Cells(nextRows, 6).Formula = "=C" & nextRows & "-P" & nextRows ' F
- If .Cells(nextRows, 6).Value < 0 Then .Cells(nextRows, 6).Font.Color = 1
- .Cells(nextRows, 7).Formula = "=D" & nextRows & IIf(nextRows = 3, "", "-D" & nextRows - 1) ' G
- If .Cells(nextRows, 7).Value < 0 Then .Cells(nextRows, 7).Font.Color = 1
- .Cells(nextRows, 8).Formula = "=E" & nextRows & IIf(nextRows = 3, "", "-E" & nextRows - 1) ' H
- If .Cells(nextRows, 8).Value < 0 Then .Cells(nextRows, 8).Font.Color = 1
- End With
- End Sub
複製代碼
|
|