Link to home
Start Free TrialLog in
Avatar of Magpie Bavarde
Magpie BavardeFlag for France

asked on

VBA : ActiveCell vs. Selection

Hello the experts,

byundt has been kind enough to help me improve several VBA codes

He suggests each time to use "ActiveCell" rather than "Selection" but also tells that if I got empty cells, then "ActiveCell" won't work and it's better to use "Selection"

As I often have empty cells in my files I'm tempted to always choose the "Selection" option

I would just like to know why "ActiveCell" is better and what are the risks with "Selection" ?

Thank you very much for your help,

Mélanie
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

I don't know exactly what byundt said and I don't know what you want to do with the active (blank) cell, but you can still refer to it's address, value or any other property.
The thing you should avoid if at all possible is selecting things in your code, because the user may change what is selected while the macro is running which may lead to unexpected results, and also "selecting" takes time. That time may be very small but it can add up.
ASKER CERTIFIED SOLUTION
Avatar of byundt
byundt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Magpie Bavarde

ASKER

That's crystal clear. Thank you so much !!
Thank you very much !
C'est rien. Mon plaisir.