+ Reply to Thread
Results 1 to 4 of 4

setting up formula to drag

Hybrid View

  1. #1
    Registered User
    Join Date
    02-27-2009
    Location
    San Deigo, CA
    MS-Off Ver
    Excel 2008 Mac
    Posts
    2

    setting up formula to drag

    I need some help manipulating data into a usable format with some additional calculations. Here is a sample of what it looks like in Excel (Letters at top and Numbers on left are excel spreadsheet inputs; all others are part of the data file):

    A B C D E F G H I J K L M
    1 1 2 3 4 5 6 7 8 9 10 11 12
    2 A 25 27 49 13 15 21 24 21 17 305 327 343
    3 B
    4 C
    5 D
    6 E
    7 F
    8 G
    9 H
    10
    11 Read 2:EM Spectrum
    12 Wavelength 5 (579 nm)
    13 1 2 3 4 5 6 7 8 9 10 11 12
    14 A 21 17 38 17 22 22 27 21 23 338 349 354
    15 B
    16 C
    17 D
    18 E
    19 F
    20 G
    21 H

    Every 3 data points I need to take the average. I set up another sheet to condense the data and get rid of the extra lines (ie B-H) like this:

    *Column A on separate spreadsheet*
    AVERAGE(B2:D2)
    AVERAGE(E2:G2)
    AVERAGE(H2:J2)
    AVERAGE(K2:M2)

    *Column B on separate spreadsheet*
    AVERAGE(B14:D14)
    AVERAGE(E14:G14)
    AVERAGE(H14:J14)
    AVERAGE(K14:M14)

    Now I have over 140 series like this and want to drag and drop the formula to take the AVERAGE and eventually STDEV of all of them. The problem is each time I drag to fill the formula into the next column (C to infinity) it just shifts the data series to the left so now it is:

    *Column C on separate spreadsheet*
    AVERAGE(E2:G2)
    AVERAGE(H2:J2)
    AVERAGE(K2:M2)
    AVERAGE(N2:P2)

    *Column D on separate spreadsheet*
    AVERAGE(E14:G14)
    AVERAGE(H14:J14)
    AVERAGE(K14:M14)
    AVERAGE(N14:P14)

    When I really want it to have Column C look like this:
    AVERAGE(B26:D26)
    AVERAGE(E26:G26)
    AVERAGE(H26:J26)
    AVERAGE(K26:M26)

    I'm not sure what I'm missing. I've tried setting up 4-5 columns with the *correct* formula, highlighted all 4-5 columns with said formulas, and dragged the formula with the same result of the shift to the left happening. Any ideas on how to make this work that don't involve me typing in each formula for all 140 points?
    Last edited by VBA Noob; 02-27-2009 at 07:51 PM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: setting up formula to drag

    Well i wouldn't recommend it buy in col A
    =AVERAGE(INDIRECT("B"&COLUMN()*12-10&":D"&COLUMN()*12-10))
    will increment
    2,14,26........
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

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

    Re: setting up formula to drag

    If I have understood you correctly I think you want the following

    Averages Sheet ! A1
    =AVERAGE(INDEX(Sheet1!$B$1:$IV$2000,2+(12*(COLUMNS($A1:A1)-1)),1+(3*(ROWS(A$1:A1)-1))):INDEX(Sheet1!$B$1:$IV$2000,2+(12*(COLUMNS($A1:A1)-1)),3+(3*(ROWS(A$1:A1)-1))))
    The above can be copied down and across as required ...

    An alternative using OFFSET which though easier to follow is Volatile (bad) would be:

    Averages Sheet ! A1
    =AVERAGE(OFFSET(Sheet1!$B$2,12*(COLUMNS($A1:A1)-1),3*(ROWS(A$1:A1)-1),1,3))
    Again like the above this could be copied down and across as required.

    If it's possible you may have #DIV/0! errors arising from your formulae (ie empty data sets being averaged) you could encase either of the above within something along the lines of:

    =LOOKUP(9.99999999999999E+307,CHOOSE({1,2},0, one of above formulae))
    This would return 0 instead of #DIV/0!

    I hope that helps.

  4. #4
    Registered User
    Join Date
    02-27-2009
    Location
    San Deigo, CA
    MS-Off Ver
    Excel 2008 Mac
    Posts
    2

    Smile Re: setting up formula to drag

    Thank you, thank you, thank you! After spending all day today at work without checking to see if someone responded and worrying about all the data entry I had in front of me tonight, this made my day.

    =AVERAGE(INDEX(Sheet1!$B$1:$IV$2000,2+(12*(COLUMNS($A1:A1)-1)),1+(3*(ROWS(A$1:A1)-1))):INDEX(Sheet1!$B$1:$IV$2000,2+(12*(COLUMNS($A1:A1)-1)),3+(3*(ROWS(A$1:A1)-1))))

    worked fantastic.

    Thank you again so much!

+ 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