Help with Newbie question - Cell Reference

F

fre

When writing a function in a cell, it always refers to that cell,
regardless if it moves. (Rows and columns are inserted) When writing
in VBA how do I make VBA track the cell's movement, so that when I
insert rows and columns with VBA code it is still referring to the
same cell?

Here is what I am using:

MyVAR = Cells(20, 6).Value 'If I insert rows and columns it still
refers to cell 20,6

Thanks in advance for any help with this!
 
D

Dave Peterson

You could name that cell (insert|name|define)

Then you could use:

myVar = worksheets("sheet1").range("mynamehere").value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top