ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet.copy changes references (https://www.excelbanter.com/excel-programming/323075-worksheet-copy-changes-references.html)

Marco[_4_]

Worksheet.copy changes references
 
Hi everybody,

We've got a problem with a macro in Excel. The macro
copies 2 worksheets to a new document. Worksheet A has
some formulas referencing cells on Worksheet B. First B is
copied to the new workbook, then A. The formulas on the
copied worksheet A are now referencing the original cell
of worksheet B, instead of the copied ones in the same
workbook.

Can anybody tell me how to keep the references within the
same workbook?

Thanks in advance,

Marco.


Ole Michelsen

Worksheet.copy changes references
 
If the addresses in the copied "worksheet B" are exactly identical to the
new addresses A1 = A1, then you could use local addresses. NewAddress =
Myrange.Address(false,false).
ActiveCell.Formula = NewAddress
You might have to write formulas like = NewAddress1 & "+" & NewAddress2

Ole Michelsen


"Marco" wrote in message
...
Hi everybody,

We've got a problem with a macro in Excel. The macro
copies 2 worksheets to a new document. Worksheet A has
some formulas referencing cells on Worksheet B. First B is
copied to the new workbook, then A. The formulas on the
copied worksheet A are now referencing the original cell
of worksheet B, instead of the copied ones in the same
workbook.

Can anybody tell me how to keep the references within the
same workbook?

Thanks in advance,

Marco.




Dave Peterson[_5_]

Worksheet.copy changes references
 
One option is to copy both worksheets at the same time.

Another is to convert your formulas to text, copy the worksheet, and change the
text formulas back to formulas

Essentially...
edit|replace
what: =
with: $$$$$$=
replace all

copy the sheet(s)

then edit|replace
what: $$$$$$=
with: =
replace all

One more option is to point at your new workbook: Edit|links|change source

Marco wrote:

Hi everybody,

We've got a problem with a macro in Excel. The macro
copies 2 worksheets to a new document. Worksheet A has
some formulas referencing cells on Worksheet B. First B is
copied to the new workbook, then A. The formulas on the
copied worksheet A are now referencing the original cell
of worksheet B, instead of the copied ones in the same
workbook.

Can anybody tell me how to keep the references within the
same workbook?

Thanks in advance,

Marco.


--

Dave Peterson


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

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