For years I’ve been saying don’t Select or Activate in your VBA code unless you really need to. But I’ve forgotten when I need to, so I want to make a list.
Conditional Formatting: When you add conditional formatting, a formula with relative references (no dollar signs) will be relative to the ActiveCell rather than the cell to which you are adding the CF. I think there’s a way around this, but I’ve found it’s just easier to select the cell, apply the CF, and get on with your life.
Sheet2.Range(“A1”).FormatConditions.Add xlExpression, , “=G5>1”
Zooming: I think Tushar once said about zooming, “Don’t do that”. Good advice. But if you must zoom in VBA, you have to select the sheet and change the Zoom property of the ActiveWindow object. I couldn’t believe this was true, but Jon Peltier confirmed it recently via Twitter. I still think it’s a poor design, but the Excel object model has so few of these oddities that I tend to give it a pass when I come across one.
That’s what I’ve got – two whole instances where selecting is necessary or preferred. I seem to remember something about shapes having to be selected, but I work with shapes even less than zooming, which is to say almost never. When do you have to select or activate?