Skip to main content
added 16 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110

From (code generated with macro recorder):From (code generated with macro recorder):

To:To:

From:From:

To:To:

From (code generated with macro recorder):

To:

From:

To:

From (code generated with macro recorder):

To:

From:

To:

Minor grammar/spelling fixes
Source Link
TylerH
  • 21.3k
  • 84
  • 84
  • 121

You may access them with []. Which, which is really beautiful, compared to the other way. Check yourself:

Try always to referreference the Worksheet as well

This is probably the most common mistake at thein . Whenever you copy ranges, sometimes the worksheet is not referredreferenced and thus VBA considers the wrong sheet the ActiveWorksheet.

  • A good example, of when you could be justified to usein using .Activate and .Select is when you want make sure, that a specific Worksheet is selected for visual reasons. E.g., that your Excel would always open with the cover worksheet selected first, disregadingdisregarding which which was the activesheetActiveSheet when the file was closed. Thus, something like the code below is absolutely

okThus, something like the code below is absolutely OK:

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

Try always to refer the Worksheet as well

This is probably the most common mistake at the . Whenever you copy ranges, sometimes the worksheet is not referred and thus VBA considers the ActiveWorksheet.

  • A good example, when you could be justified to use .Activate and .Select is when you want make sure, that a specific Worksheet is selected for visual reasons. E.g., that your Excel would always open with the cover worksheet selected first, disregading which which was the activesheet when the file was closed. Thus, something like the code below is absolutely

ok:

You may access them with [], which is really beautiful, compared to the other way. Check yourself:

Try always to reference the Worksheet as well

This is probably the most common mistake in . Whenever you copy ranges, sometimes the worksheet is not referenced and thus VBA considers the wrong sheet the ActiveWorksheet.

  • A good example of when you could be justified in using .Activate and .Select is when you want make sure that a specific Worksheet is selected for visual reasons. E.g., that your Excel would always open with the cover worksheet selected first, disregarding which which was the ActiveSheet when the file was closed.

Thus, something like the code below is absolutely OK:

It is a philosophic question, whether ActiveWindow is the same as .Activate, but as far as it was mentioned in the comments,I have added it.
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
never say never ... in #VBA
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
added 1008 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
added 1008 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
added 644 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
deleted 481 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
added 573 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
added 2 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
added 2 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
added 227 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
deleted 43 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
added 437 characters in body
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading
Post Undeleted by Vityata
Post Deleted by Vityata
Source Link
Vityata
  • 43.8k
  • 10
  • 64
  • 110
Loading