PDA

View Full Version : Keeping references to cell when moving/inserting/deleting



jungix
08-28-2006, 10:30 AM
Want a formula refers to a cell and the cell is moved in VBA the content of the formula moves with it (except maybe if it is referred to with $).

However, in VBA if I insert a column in my Excel sheet, the references in my VBA code won't change.

I know I could define my ranges in VBA with find and offsets but that would be very heavy.

Is there a simple way for code to be updated as we move/delete/insert cells/rows/columns?

Cyberdude
08-28-2006, 08:23 PM
I'm sure someone else will give you a better answer, but I feel pretty certain that nothing is going to modify your VBA code for you automatically. I'm guessing that the only solution is to use named ranges that are selfupdating. That way your code doesn't care if the size of a range changes.

Zack Barresse
08-29-2006, 09:13 AM
CD has it, named ranges or you can code your logic to find the cell for you, which seems (generally and usually) infinitely more difficult and complex.