ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to change references (https://www.excelbanter.com/excel-programming/273517-code-change-references.html)

Steve[_27_]

Code to change references
 
Currently I have:
File 1 = Summary File 2 = CCO
'[Summary.xls]May-03'!J19: ='[CCO.xls]Jan-03'!$N$467
'[Summary.xls]Jun-03'!J19: ='[CCO.xls]Jan-03'!$N$467
'[Summary.xls]Jul-03'!J19: ='[CCO.xls]Jan-03'!$N$467

What is the code to change them to:

'[Summary.xls]May-03'!J19: ='[CCO.xls]May-03'!$N$471
'[Sunnary.xls]Jun-03'!J19: ='[CCO.xls]Jun-03'!$N$472
'[Summary.xls]Jul-03'!J19: ='[CCO.xls]Jul-03'!$N$473

The code needs to change the reference on the right side of the equal sign.
1. For each line, the code needs to change the sheet name to the sheet name on
the left side of the equal sign, ie,
line 1: Jan-03 to May-03
line 2: Jan-03 to Jun-03
line 3: Jan-03 to Jul-03
The lines could be any three months so the code must be generic!

2. For each line, the row reference must be 467 + (Month# -1)in the line, ie,
In line 1, May is Month#5 so the row reference is 467 + (5-1) = 471
in line 2, June is Month#6 so the row reference is 467 + (6-1) = 472
in line 3, July is Month#7 so the row reference is 467 + (7-1) = 473

Thanks for your help!

Steve




All times are GMT +1. The time now is 10:12 AM.

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