+ Reply to Thread
Results 1 to 4 of 4

Macro to Change Worksheet Formulas

  1. #1
    Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2007
    Posts
    438

    Macro to Change Worksheet Formulas

    Hello,

    I am wondering if it is possible to change part of a worksheet formula via vba?

    In the attached file, sheet 2 holds the data and the named ranges. What I need is to be able to change the formula in sheet2, in the range B4:B6 from:

    =SUMPRODUCT(--(RName=$A4),--(RWeek=B$2),RQty)

    to

    =SUMPRODUCT(--(RName=$A4),--(RMonth=C$2),RQty)


    Can this be done with macro?
    Please answer only if you have vba solution because in the real file the range with the formulas is big and I do not want to make any changes to its structure.
    I just need to be able to switch the formulas in the cells B4,B5 and B6

    I would appreciate your help!
    Attached Files Attached Files
    Last edited by Bob@Sun; 04-08-2010 at 01:26 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Macro to Change Worksheet Formulas

    Hows this?:

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2007
    Posts
    438

    Re: Macro to Change Worksheet Formulas

    It is working, but RName=$A4 must change. With this code I get one formula for all rows.

    Can you modify that?

    Thanks

  4. #4
    Forum Contributor Bob@Sun's Avatar
    Join Date
    09-03-2009
    Location
    Montuak, Usa
    MS-Off Ver
    Excel 2007
    Posts
    438

    Re: Macro to Change Worksheet Formulas

    I got it!

    Please Login or Register  to view this content.
    Thanks for the help!
    Last edited by Bob@Sun; 04-08-2010 at 02:12 PM.

+ 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