Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Changing Formula References

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'!F 5)


EXAMPLE RESULTS:

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Changing Formula References

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'!F 5)


EXAMPLE RESULTS:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing multiple column references in a formula JackRosieMaisie Excel Worksheet Functions 5 June 17th 09 03:41 PM
changing cell references Sly Excel Worksheet Functions 5 July 29th 07 02:10 PM
Formula automatically changing cell references Nina Excel Worksheet Functions 1 February 8th 06 09:55 PM
Changing many references at a time. rmellison Excel Discussion (Misc queries) 2 September 22nd 05 04:41 PM
Changing Formula References in Visual Basic EmmaC. Excel Programming 0 March 1st 04 04:08 PM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"