Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting/adding column without losing code

Status
Not open for further replies.

TTThio

Programmer
May 3, 2001
185
US
Hallo,

can we insert or add column without losing codes that is applied to certain column?

For example, in the code:
range ("C1:C500").value = X

then we insert a column between B & C, as a result, the previous column C is moved to the right and becomes column D. I would like the code is still applicable for that column though, not the new column C.

I know the code can be preserved if the range is named. So that it doesn't matter where is the position, it will always be refered as a name.

However, as I will need to loop through different sheets applying the same code for the same columns, exp.
Sheet1!A1
Sheet2!A2, etc, I face another difficulity.

Can anybody please help me with this? Thanks a lot.

 
The only way I know how to do this is by using named ranges. Then, when you insert columns, the applied names stay with the appropriate cells. For example, if you name Sheet1!A1 as Value1, you can address the cell using [Value1].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top