1

Need help in optimizing the below block of code to copy and paste a range of selection from one sheet to another sheet. I have 3-4 blocks similar to the one below. Would be helpful if somone could help out with an optimized version of the code below

Note: I am a coding Beginner

Sheets("Company Profile").Select
    Range("D15").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Sheets(client_name).Select
    Range("D2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
    Range("D2").Select

Getting expected result but need to speed up

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • 3
    Turn off screen updating, events and calculations. – Skin Apr 05 '19 at 10:17
  • 1
    [Avoid using `Select` and `Activate`](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba?r=SearchResults&s=1|217.4492). Not only is it slow, it's also error-prone. – jsheeran Apr 05 '19 at 10:24
  • 1
    Also, read up on why its not recommended to use things like `Select` and `Activate` in `VBA`. **Tip**: the way you are performing the copy, basically you pasting things into clipboard and then pasting from clipboard. If you do something like: `.Copy `, it's a copy without using clipboard (as such). This way you are not clogging your memory with unwanted stuff – Zac Apr 05 '19 at 10:25

0 Answers0