The code just listed activates each sheet in turn, then selects cell A1 on that sheet, and finally
assigns a new value to that cell’s FormulaR1C1 property. This sequence of steps mimics the
steps that most users would follow if they were working manually.
In VBA, everything but the
last step in the sequence is unnecessary. That is, you can replace the following instructions:
Sheet.Activate Range("A1").Select ActiveCell.FormulaR1C1 = "Sheet" + Str(n)with a single instruction:
Sheet.Range("A1").FormulaR1C1 = "Sheet" + Str(n)The benefit of this change is that it enables the macro to run faster because Excel is no longer required to activate sheets and select cells.