View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Adam Adam is offline
external usenet poster
 
Posts: 287
Default select cell by variable name

Hi,

When I insert a row after I have recorded a macro, the macro stops referring
to the correct cells. To fix this, I tried naming all the cells variables
and having the macro refer to the variable names instead of the cell location
(ie. A1).

So instead of:

Range("A1").Select
Selection.Copy

I tried:

Range("pop1d").Select
Selection.Copy

but I get an error message that says "select method of range class failed".
What is the correct way to refer to variable names in visual basic? Also, is
there any other way to have visual basic auto-update and refer to the correct
cells if I were to insert a row after recording the macro?

Thanks,

Adam