+ Reply to Thread
Results 1 to 13 of 13

How to copy formula and it following a pattern?

  1. #1
    Registered User
    Join Date
    04-07-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    6

    How to copy formula and it following a pattern?

    Hello, I'm new to the forum and have a question about Excel. I have looked all over the web, but have failed in coming up with a solution. Below is my issue:

    I'm working with one worksheet that has two sheets,named PAGE 1 and PAGE 2. PAGE 1> column B contains dollar amounts for Gross Revenue starting at cell B131 and ending on cell B147.

    PAGE 2 has a row in which three of the cells from PAGE 1 are added, for example B131-133. On the same row, but the next column, the same formula is entered but with each cell incrementing by one. Below is the formulas to show you what I mean.

    ='PAGE 1'!$B133+'PAGE 1'!$B134+'PAGE 1'!$B135

    ='PAGE 1'!$B134+'PAGE 1'!$B135+'PAGE 1'!$B136

    As you can see, on the same row, but next column, the formula for the sum is increased by one cell each time.

    What I'm trying to do is be able to copy this formula over to the next column, but within the same row, and following this pattern.

    I've read and tried the OFFSET function, but I cannot get it to work.

    Any help will be appreciated it. Thank you.

  2. #2
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: How to copy formula and it following a pattern?

    There is no simple formula to do what you want.
    You can try this:
    On Page 2 1st cell: =sum(indirect("'Page 1'!$B"&132+column(A1)&":$B"&132+column(A1)+2))
    then copy it into the cell to the right

    see if that gives you the results you want.

    If you don't want it in column A then use =Sum(Indirect("'Page 1'!B"&132

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to copy formula and it following a pattern?

    You can do this using INDEX but we need to know in which column the first formula appears...

    For the sake of an example I am assuming the first formula on PAGE 2 appears in cell B2, the second in C2 and so on through to Q2

    'PAGE 2'!B2:
    =SUM(INDEX('PAGE 1'!$B$131:$B$147,COLUMNS($B2:B2)):INDEX('PAGE 1'!$B$131:$B$147,COLUMNS($B2:B2)+2))
    copy across to Q2

    You mentioned OFFSET... you could use this:

    'PAGE 2'!B2:
    =SUM(OFFSET('PAGE 1'!$B$131:$B$147,COLUMNS($B2:B2)-1,,3,1))
    copy across to Q2

    However, it is imperative you note that while it is undoubtedly a shorter and more elegant formula OFFSET is in fact Volatile (a bad thing, as incidentally is INDIRECT (prior post)), so if you can avoid using it (as shown above with INDEX:INDEX) you should do... sometimes OFFSET is very useful but normally it's better to adopt an INDEX approach if you can - IMO FWIW!

  4. #4
    Registered User
    Join Date
    04-07-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to copy formula and it following a pattern?

    DonkeyOte,

    Thank you for the formula. The first formula appears on cell CC8 and from Page 1 it's only adding three cells at a time. I copied and edited your formula to the below:

    =SUM(INDEX('PAGE 1'!$B$133:$B$135,COLUMNS($CC8:CC8)):INDEX('PAGE 1'!$B$133:$B$135,COLUMNS($CC8:CC8)+2))

    When I copy the formula over the next column in the same row, it changes to this:

    =SUM(INDEX('PAGE 1'!$B$133:$B$135,COLUMNS($CC8:CD8)):INDEX('PAGE 1'!$B$133:$B$135,COLUMNS($CC8:CD8)+2))

    Now, the first time I tried it, it worked like a charm, but I got an #HREF! on the cell CN8 and I could not figure it out why.

    I started from scratch, but now it only works on the first cell and not on any other one.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to copy formula and it following a pattern?

    Why are you only using B133:B135 ... per the example this should be inclusive of all data ... ie in the sample B131:B147... I suspect now it's B133:Bxxx ... the error is because you have not referenced the entire range... the use of COLUMNS will ensure only the correct rows are used in each calculation.

  6. #6
    Registered User
    Join Date
    04-07-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to copy formula and it following a pattern?

    I don't know

    I now understand the formula completely, but just in case, could you break it down for me?

    I changed the formula back to how you set it up first and it's working flawless.

    Question, the current range for Page 1 is B131-B137, but a new row is added every month. How can the formula take into affect such change for every month that is added? Can the first formula simply be changed and all the others will reflect such change?

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to copy formula and it following a pattern?

    You may find it easiest to create a Dynamic Named Range and use that ... see: http://www.contextures.com/xlNames01.html

    eg:

    Name: _data
    RefersTo: ='PAGE 1'!$B$131:INDEX('PAGE 1'!$B:$B,MATCH(9.99999999999999E+307,'PAGE 1'!$B:$B))

    Then formula should then use _data as it's Range as opposed to $B$131:$B$137 as is presently the case...
    With a Dynamic Named Range as you add new rows the range should adapt, in truth however it will depend on what sits beneath the final row on Page 1 if anything ... the above approach assumes that the last row of data can be identified by finding the last numeric value in Column B.

  8. #8
    Registered User
    Join Date
    04-07-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to copy formula and it following a pattern?

    Column B has the last cell as being the average of the entire column, so I don't know if that would work.

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to copy formula and it following a pattern?

    In which case you could subtract 1 from the MATCH result:

    RefersTo: ='PAGE 1'!$B$131:INDEX('PAGE 1'!$B:$B,MATCH(9.99999999999999E+307,'PAGE 1'!$B:$B)-1)

  10. #10
    Registered User
    Join Date
    04-07-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to copy formula and it following a pattern?

    Got it, I'll give that a try. Thank you.

  11. #11
    Registered User
    Join Date
    04-07-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to copy formula and it following a pattern?

    Alright, gave it a try and it works flawless, you're a genius.

  12. #12
    Registered User
    Join Date
    08-09-2013
    Location
    Indiana, United States
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: How to copy formula and it following a pattern?

    I am having a similar difficulty, but I don't fully understand the formula used to remedy this problem.

    On Page2 B4:
    I summing data from Page1 from B6:Y6
    and in B5:
    I am summing data from Page1 from B9:Y9

    Your solution should work in my case, but I cannot figure out what the arguments truly mean to the formula.

    Help is appreciated.

    EDIT: I understand that this is an old thread, but I figured making my own thread wasn't necessary.

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: How to copy formula and it following a pattern?

    Animosity,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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