返回列表 上一主題 發帖

[發問] 將current year 的數字複製到last year

[發問] 將current year 的數字複製到last year

將Current year 的數字複製到Last year 的column, 直至出現 End 字樣為止.
請問那裡出錯, 應如何更正?

Sub Macro5()

B = 2
C = 2
D = 3
Do Until Sheets("Sheet1").Range(Cells(5, B), Cells(5, B)) = "End"
    Sheets("Sheet1").Range(Cells(5, C), Cells(43, C)).Select
    Selection.Copy
    Sheets("Sheet1").Range(Cells(5, D), Cells(43, D)).Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False

    B = B + 1
    C = C + 2
    D = D + 2
Loop

End Sub

move.rar (7.06 KB)

  1. Sub Macro5()
  2.     With Sheets("sheet1")
  3.         c = 2
  4.         Do Until .Cells(5, c) = "End"
  5.             .Range(.Cells(5, c + 1), .Cells(43, c + 1)) = .Range(.Cells(5, c), .Cells(43, c)).Value
  6.             c = c + 2
  7.         Loop
  8.         End With
  9.     End Sub
複製代碼

TOP

回復 2# oobird


    謝謝回覆:)

TOP

        靜思自在 : 【時間成就一切】時間可以造就人格,可以成就事業,也可以儲積功德。
返回列表 上一主題