+ Reply to Thread
Results 1 to 7 of 7

Macro to change formula

Hybrid View

yogesh thakker Macro to change formula 03-13-2010, 02:42 AM
6StringJazzer Re: Macro to change formula 03-13-2010, 12:13 PM
yogesh thakker Re: Macro to change formula 03-15-2010, 02:01 AM
teylyn Re: Macro to change formula 03-15-2010, 02:14 AM
yogesh thakker Re: Macro to change formula 03-15-2010, 02:29 AM
teylyn Re: Macro to change formula 03-15-2010, 03:42 AM
6StringJazzer Re: Macro to change formula 03-15-2010, 10:35 AM
  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,744

    Re: Macro to change formula

    I suspect the underlying problem is with your data organization. It is very cryptic and difficult to understand. However, note that I have attached a solution that uses a macro (see below).

    As near as I can figure, you have these blocks of data, each with some sort of header record followed by several data records. Then your "present value matrix" does a calcuation for each data record, but has absolute references to elements of the header record (such as $AE$2).

    Therefore, when adding a new data block, you have to update the formula in your "present value matrix" (in column BN) to refer to the appropriate header record (such as changing to $AE$9).

    One suggestion is that you repeat the header data in every record, instead of just putting it at the beginning. That allows you to use relative references in your formulas that can be copied to subsequent rows with no macros, no editing. That approach also allows for other analysis, such as with pivot tables, though you may not need that.

    ...that is what I have been doing using Word find and replace command.
    I will repeat that if you have to do this, you should use the find & replace that's already in Excel. There is no need to copy formulas into Word, change them, then copy them back.

    If you have any idea how a macro can be used in this situation, please help me.
    It would be possible to do this with a macro. The way I would approach it is to define a user-defined function to retrieve the date that you are now getting from column AE. It would look like this:
    ' Return the previous non-blank value at or above the reference
    Public Function GetPreviousNonempty(r As Range) As Variant
       Do Until (Not IsEmpty(r) And r <> "") Or r.Row = 1
          Set r = r.Offset(-1, 0)
       Loop
     
       GetPreviousNonempty = r.Value
    End Function
    This allows you to use relative references for the data in AE. I have attached a revised workbook for your reference.

    However, I still can't figure out what you are doing when you
    replace $3 with $10
    Attached Files Attached Files
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1