Skip to main content
5 of 15
added 2 characters in body
Vityata
  • 43.8k
  • 10
  • 64
  • 110

This is an example to avoid Select and ActiveCell when we want to copy columns from WorkSheet to another WorkSheet.

From:

Sheets("Source").Select Columns("A:D").Select Selection.Copy Sheets("Target").Select Columns("A:D").Select ActiveSheet.Paste 

To:

Worksheets("Source").Columns("A:D").Copy Destination:=Worksheets("Target").Range("a1") 

Something nice for named ranges. You may access them with []. Which is really beautiful, compared to the other way. Check yourself:

Dim Months As Range Dim MonthlySales As Range Set Months = Range("Months") Set MonthlySales = Range("MonthlySales") Set Months =[Months] Set MonthlySales = [MonthlySales] 

The example from above would look like this:

Worksheets("Source").Columns("A:D").Copy Destination:=Worksheets("Target").[A1] 

Usually, if you are willing to select, most probably you are copying something. If you are only interested in the values, this is a good option to avoid select:

Range("B1:B6").value = Range("A1:A6").Value

Vityata
  • 43.8k
  • 10
  • 64
  • 110