why delete copied cells by deleting origin, after copy?

  • hello, I was copy cells of a rage to another palace, by VBA in Excel

    then I delete origin, but, when I deleting origin, copied cells deleted also.

    please tel me why?


    Code
    Set rng = Sheet_hazer.Range(Cells(2, 10), Cells(3, 12))
                rng.Select
                rng.Copy
                Cells(2, 13).Select
                Sheet_hazer.PasteSpecial
                Sheet_hazer.Range(Cells(2, 10), Cells(3, 10)).Value = ""
  • Hello and welcome to the forum,


    I don't understand your question... I tried your code but only 2 cells (J2 and J3) are deleted, not the copied cells

    Also, why do you use Pastespecial? You could simple copy-paste? Unless you only want to copy values, formulas, etc...


    Here are a few examples of your code that you can try:


  • I'm not sure if you have used the Sheet Code Name or declared a variable as Sheet_Hazer.


    If you re copying constants then


    Code
    ActiveSheet.Range("J2:L3").Cut ActiveSheet.Range("M2")
  • I'm not sure if you have used the Sheet Code Name or declared a variable as Sheet_Hazer.


    If you re copying constants then


    Code
    ActiveSheet.Range("J2:L3").Cut ActiveSheet.Range("M2")

    thank's, solved by your response.

  • Excuseme, completly solved by this:


    Code
                Set rng = Sheet_hazer.Range(Cells(2, 10), Cells(3, 12))
                Set rng4 = Sheet_hazer.Cells(2, 12 + 5)
                rng.Copy
                rng4.PasteSpecial xlPasteValues
                rng.ClearContents

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!