+ Reply to Thread
Results 1 to 4 of 4

Paste Function Value

  1. #1
    Registered User
    Join Date
    04-20-2005
    Posts
    48

    Paste Function Value

    Simplified Example without a macro:
    C11: =SUM($A2,B$3)
    I can drag that formula so it fills the range C11:F15 and it maintains the relative referencing.

    I need to be able to select a range of cells (C11:F15) and run a macro that enters the values returned by the function (=SUM($A2,B$3)).

    I'm extremely new to Excel macros, but have many years of programming and scripting experience.

    Thanks,
    JC

  2. #2
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    If you are already copying down by hand in the sheet then you could simply copy the selected cells once you have copied down and move over one column and paste special as values.

    Or do you want a macro to both copy the formula in one column and then paste the values into the rext column?

  3. #3
    Registered User
    Join Date
    04-20-2005
    Posts
    48
    I currently have to copy the formula down all the rows and then over all the columns to get the values. I then copy all the cells and paste-special->values. The reason I don't keep the formula in all the cells addresses the following two issues:

    1) People will change the value when doing custom scenarios (I know about the scenario function of Excel, but must users will not) and could potentially need to return that cell to the original value.

    2) I am using a long SUMPRODUCT function to lookup the data. Having 50k-100k SUMPRODUCT calls slows the computer down considerably.

    So, being able to highlight the cells and running a macro to insert the value the formula (not the formula itself) would be ideal.

  4. #4
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    This code will fill the selected region with the formula "=sum($A2,B$3)" while maintaining correct relative references. Then it will copy and paste special the resulting values.

    This assumes that you have selected the range from the top left to bottom right leaving your ActiveCell (the one that is not shaded) at the top left.

    Please Login or Register  to view this content.
    HTH

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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