Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default partially replace formula problem. Please help!

I have a whole bunch of formula with some parts similar like
MVJan!$A$13:$Z$68 in about 12 worksheets, but Feb will change
MVFeb!$A$13:$Z$68 and so on.

Now I want these similar formula to be placed as
INDIRECT("MV"&mth&"!$A$8:$Z$18") mth is defined name to define the cell
that I can change the month and reference area will be changed.

The problem now is that reference area is not always the same. $A$13:$Z$68
can be $A$35:$Z$177, etc.


How can I replace this kind of formula in a batch? Whats kind of code
should I use? Can I use object?


Your help is really appreciated!


Thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default partially replace formula problem. Please help!

You could probably use Find and Replace to do that, using the "look in
formulas" option.
I don't know how many sheets are involved or the ranges containing the
formulas, but you could write a macro to go through all worksheets in the
workbook, examine the .Formula value of each (appropriate) cell on them and
change the .Formula property of the ones you need to in the macro. Something
that looks a little like this:

Sub ChangeFormulas()
Dim anySheet as Worksheet
dim anyCell as Object
For Each anySheet in Worksheets
For Each anyCell in anySheet.Cells
If Left(anyCell.Formula, 7) = "=MVJan!" Then
..... and in here is where you would build a new formula
..... splitting up the old one to preserve the cell references and
..... and rebuilding it as your =INDIRECT(....) formula
End If
Next
Next
End Sub

by looking at anySheet.Cells, it could take a while to run, so if you can
refine that to a specific range of cells, it would certainly go faster.

"smart.daisy" wrote:

I have a whole bunch of formula with some parts similar like
MVJan!$A$13:$Z$68 in about 12 worksheets, but Feb will change
MVFeb!$A$13:$Z$68 and so on.

Now I want these similar formula to be placed as
INDIRECT("MV"&mth&"!$A$8:$Z$18") mth is defined name to define the cell
that I can change the month and reference area will be changed.

The problem now is that reference area is not always the same. $A$13:$Z$68
can be $A$35:$Z$177, etc.


How can I replace this kind of formula in a batch? Whats kind of code
should I use? Can I use object?


Your help is really appreciated!


Thanks

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
COUNTIF in between rows Vasilis Tergen Excel Worksheet Functions 20 January 13th 07 10:22 PM
automate replace values in formula galiant Excel Discussion (Misc queries) 2 July 9th 06 03:40 PM
conditional formatting: problem entering EOMONTH formula... Jonathan Cooper Excel Discussion (Misc queries) 1 February 6th 06 09:28 PM
formula percentage problem thinkpic New Users to Excel 4 November 2nd 05 08:04 PM
Problem with VBA returning the contents of a long formula. [email protected] Excel Discussion (Misc queries) 2 February 23rd 05 12:14 AM


All times are GMT +1. The time now is 10:06 PM.

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

About Us

"It's about Microsoft Excel"