ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   A macro that will change all column refs from one column to another? (https://www.excelbanter.com/excel-programming/292848-macro-will-change-all-column-refs-one-column-another.html)

ModelerGirl

A macro that will change all column refs from one column to another?
 
I have an array of cells that all refer to cells in column A (A30,A32
etc). I'd like to change all those references to C30,D32, etc.

Is there any way to do this? Because of other relative references i
the cells, just copying won't work.

Any help is greatly appreciated! Thanks again for all your help.

Kat

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

A macro that will change all column refs from one column to another?
 
How would we know to change A30 to C30 and A32 to D32. Is there some ryhme
or reason to the pattern.

If you really meant change A to C.

for each cell in Selection
sForm = cell.Formula
sForm = Application.Substitute(sForm,"A","C")
cell.Formula = sForm
Next

The success of this approach would depend on the formulas in the cells. If
they contain "A"'s not associated with a cell address, then you might have
to be more discriminating. If the above would work, you could just use the
built in Replace command in the edit menu and skip the macro.

--
Regards,
Tom Ogilvy

"ModelerGirl " wrote in message
...
I have an array of cells that all refer to cells in column A (A30,A32,
etc). I'd like to change all those references to C30,D32, etc.

Is there any way to do this? Because of other relative references in
the cells, just copying won't work.

Any help is greatly appreciated! Thanks again for all your help.

Kate


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com