PC Review


Reply
Thread Tools Rate Thread

Changing Formula References

 
 
scott
Guest
Posts: n/a
 
      29th Jul 2007
If I copy "EXAMPLE FORMULA" below from a cell in mySheet2 and paste special
only the formula into the same cell in mySheet3, obviously the cell in
mySheet3 will retain the same cell references used in the mySheet2 copied
formula.

My problem with this is after pasting EXAMPLE FORMULA from mySheet2 to
mySheet3, I need the mySheet3 formula to look like EXAMPLE RESULTS. My
question is there a way using vba to iterate through a spreadsheet and
modify cell references?

For example, on mySheet3, after copy pasting special the formulas, I'd loop
through all cells changing any reference to mySheet2 to be mySheet3. Then
I'd change all formulas using mySheet1 to use mySheet2.

Can this be done with code or any other way?


EXAMPLE FORMULA:

=IF('mySheet1'!B5="","",'mySheet1'!B5+'mySheet2'!F5)


EXAMPLE RESULTS:

=IF('mySheet1'!B5="","",'mySheet2'!B5+'mySheet3'!F5)


 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      29th Jul 2007
turn on the macro recorder and do

Edit=>Replace

What: String to be Replace
With: String to use as a replacement

Turn off the macro recorder and use the recorded code. Make sure you have
selected the option to do replacements on less than the whole formula in the
cell.


Worksheets("Sheet1").Cells.Replace _
What:="Sheet2", _
Replacement:="Sheet1", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
--
Regards,
Tom Ogilvy

regards,
Tom Ogilvy


"scott" wrote:

> If I copy "EXAMPLE FORMULA" below from a cell in mySheet2 and paste special
> only the formula into the same cell in mySheet3, obviously the cell in
> mySheet3 will retain the same cell references used in the mySheet2 copied
> formula.
>
> My problem with this is after pasting EXAMPLE FORMULA from mySheet2 to
> mySheet3, I need the mySheet3 formula to look like EXAMPLE RESULTS. My
> question is there a way using vba to iterate through a spreadsheet and
> modify cell references?
>
> For example, on mySheet3, after copy pasting special the formulas, I'd loop
> through all cells changing any reference to mySheet2 to be mySheet3. Then
> I'd change all formulas using mySheet1 to use mySheet2.
>
> Can this be done with code or any other way?
>
>
> EXAMPLE FORMULA:
>
> =IF('mySheet1'!B5="","",'mySheet1'!B5+'mySheet2'!F5)
>
>
> EXAMPLE RESULTS:
>
> =IF('mySheet1'!B5="","",'mySheet2'!B5+'mySheet3'!F5)
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to navigate within a formula without changing cell references? Héctor Miguel Microsoft Excel Discussion 0 10th Sep 2008 05:33 AM
Relative Formula References NOT changing After Insert From VB David Microsoft Excel Programming 5 21st Jul 2008 10:25 PM
Formula Link References Changing =?Utf-8?B?SmFzb24=?= Microsoft Excel Crashes 0 7th Sep 2006 02:22 PM
Formula automatically changing cell references =?Utf-8?B?TmluYQ==?= Microsoft Excel Worksheet Functions 1 8th Feb 2006 09:55 PM
Changing Formula References in Visual Basic EmmaC. Microsoft Excel Programming 1 1st Mar 2004 06:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 PM.