+ Reply to Thread
Results 1 to 12 of 12

When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

  1. #1
    Forum Contributor
    Join Date
    08-20-2009
    Location
    Plymouth, England
    MS-Off Ver
    Excel 2013
    Posts
    149

    When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Hi all,

    Not sure how to explain this, but by default if you want to copy a formula down a worksheet it moves one cell at a time. eg if you have in cell A1 the formula =SUM(B1:Z1), if you were to drag down to cell A2 you would get =SUM(B2:Z2) Is there any way I can drag the formula and it moves down a certain number of cells, so if A1 is =SUM(B1:Z1), when I drag it it changes in cell A2 to =SUM(B145:Z145)?

    Hope this makes sense.

    Thanks,

    Luke
    Last edited by lukela85; 02-02-2017 at 08:06 AM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Try it like this:

    =SUM(INDEX($A:$Z,(ROWS($1:1)-1)*144+1,0))

    then copy down.

    Hope this helps.

    Pete

    EDIT: Sorry, should be $B:$Z

    Pete

  3. #3
    Forum Contributor
    Join Date
    08-20-2009
    Location
    Plymouth, England
    MS-Off Ver
    Excel 2013
    Posts
    149

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Thanks Pete,

    I was using a very simple example to try and explain what I meant.

    This is my current formula in cell Y4:

    =IF(X4<>"Error",INDEX(Data!$B147:$B290,MATCH(X4,Data!P147:P290,0)),"Error")

    When I drag the formula down to cell Y5 what I'd like to see is this:

    =IF(X5<>"Error",INDEX(Data!$B291:$B434,MATCH(X5,Data!P291:P434,0)),"Error")

    So the cell references in cells B & P have effectively jumped 144 cells. Is it possible to do this?

    Thanks,

    Luke

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    It would help if you attached a sample Excel workbook, so that I can play about with different formulae.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Note that the Paperclip icon does not work.

    Pete

  5. #5
    Forum Contributor
    Join Date
    08-20-2009
    Location
    Plymouth, England
    MS-Off Ver
    Excel 2013
    Posts
    149

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Thanks Pete.

    You'll see that in each cell from B4 over to AK4 (minus a few blank cells) that each formula references the "Data" sheet. It's these cell references which I would like to "jump" 144 cells so I don't have to manually amend each cell (would be around 900!)

    Thanks,

    Luke
    Attached Files Attached Files

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Okay, thanks for that Luke.

    I'll be going out shortly, so I'll pick this up again when I get back (if no-one else has chipped in).

    Pete

  7. #7
    Forum Contributor
    Join Date
    08-20-2009
    Location
    Plymouth, England
    MS-Off Ver
    Excel 2013
    Posts
    149

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Thanks Pete.

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Your file is very confusing (to an outsider). It would appear that in the data sheet your have a series of measurements taken each day at 10 minute intervals (which is where the 144 comes from, i.e. 6 readings/rows per hour * 24 hours), but you don't necessarily want to analyse them for a particular day as the entry in column A of the Detail sheet suggests - rather, your "day" may cover a period from 9:10am on one day to 9:00am on the next day. Consequently, your group of formulae are looking at different ranges, each spanning 144 rows. (That's a quick synopsis for my benefit).

    I think it will be easier for you to adjust those ranges using the INDIRECT function, which allows you to "calculate" a range reference as a string of text and then get Excel to convert this into an appropriate reference that it understands. For example, you have this formula in cell E4:

    =IF(AN4="Y",MIN(Data!E57:E200),"Error")

    You would need to change this to (changes in red):

    =IF(AN4="Y",MIN(INDIRECT("Data!E"&57+(ROWS($1:1)-1)*144&":E"&200+(ROWS($1:1)-1)*144)),"Error")

    To understand what is happening, lets just focus in on the text that is formed within the INDIRECT function. The term ROWS($1:1) returns 1, and we subtract 1 from this giving zero, and this is multiplied by 144 and then added on to either 57 or 200. So the resulting text is:

    "DATA!E" & 57 & ":E" & 200

    which evaluates to what you have already. However, when the formula is copied down onto the next row the term controlling the row references becomes ROWS($1:2), which returns 2 and subtracting 1 from this will give 1 which is multiplied by 144. Thus, 144 is added on to 57 and 200. On the third row by the same logic, 288 will be added on to 57 and 200, and so on.

    In F4 you have this formula:

    =IF(E4<>"Error",INDEX(Data!$B57:$B200,MATCH(E4,Data!E57:E200,0)),"Error")

    which is using the same row range (shown in red) in two different columns. For this formula, then, you will need two different INDIRECT functions along the lines just described, and similar for the formula in G4.

    The formula in H4 uses a different range, i.e.:

    =IF(AM4="Y",SUM(Data!Q201:Q344),"Error")

    so this would have to be changed to:

    =IF(AM4="Y",SUM(INDIRECT("Data!Q"&201+(ROWS($1:1)-1)*144&":Q"&344+(ROWS($1:1)-1)*144)),"Error")

    In summary then, for each of the formulae in the cells up to AK4, you will need to amend the row references by adding on a term +(ROWS($1:1)-1)*144, and you will need to split the sheet name and column references out into fixed strings, and then wrap the whole string with INDIRECT( ... ). After you have made those changes, then the row of formulae can be copied down to give the effect of row references "jumping" by 144 on each new row.

    Hope this helps.

    Pete

    P.S. If that takes care of your original question, please take a moment to select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete
    Last edited by Pete_UK; 01-25-2017 at 09:20 PM.

  9. #9
    Forum Contributor
    Join Date
    08-20-2009
    Location
    Plymouth, England
    MS-Off Ver
    Excel 2013
    Posts
    149

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Thanks for your help Pete.

    Yes I can see why it would look confusing.

    The purpose of the spreadsheet is to automatically list the extremes and times they occurred for each day of the month once I've downloaded the data from my weather station. For temperature and rainfall the recording period in the UK is from 0900 to 0900 each day so that's why the formulas are like that.

    I've had a play with the formula in C4 and this is what I've got:

    =IF(C4<>"Error",INDEX(INDIRECT("Data!B"&201+(ROWS($1:1)-1)*144&":B"&344+(ROWS($1:1)-1)*144)),MATCH(C4,(INDIRECT("Data!D"&201+(ROWS($1:1)-1)*144&":D"&344+(ROWS($1:1)-1)*144)),"Error")

    However I'm getting the 'too few arguments' error. I can see I'm missing a closing bracket but not sure where to put it - not sure if this is the only issue!

    Also, I have this formula in AM4:

    =IF(AND(Data!$A201=$A4,Data!$B201=0.381944444444444,Data!$A344=$A5,Data!$B344=0.375),"Y","N")

    This is to error check that the day starts at finishes at the expected time (0910 and 0900). Would you be able to show me where to put the INDIRECT functions with this formula?

    Thanks,

    Luke

  10. #10
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    why not use two criteria instead of one criteria. (i.e. "AO4" & "A4" which is date)


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    I think the long formula that you quote is in D4, not C4, and you currently have this:

    =IF(C4<>"Error",INDEX(Data!$B201:$B344,MATCH(C4,Data!D201:D344,0)),"Error")

    This should be changed to:

    =IF(C4<>"Error",INDEX(INDIRECT("Data!B"&201+(ROWS($1:1)-1)*144&":B"&344+(ROWS($1:1)-1)*144),MATCH(C4,INDIRECT("Data!D"&201+(ROWS($1:1)-1)*144&":D"&344+(ROWS($1:1)-1)*144),0)),"Error")

    You had an extra close bracket just before the MATCH in the middle, and then the end of the MATCH function had a few characters missing.

    The formula in AM4 can be written like this:

    =IF(AND(Data!$A201=$A4,Data!$B201=TIME(9,10,0),Data!$A344=$A5,Data!$B344=0.375),"Y","N")

    which is a bit easier to understand, as it is not clear what the value 0.381944444444444 actually represents. This formula will get transformed into this:

    =IF(AND(INDIRECT("Data!A"&201+(ROWS($1:1)-1)*144)=$A4,INDIRECT("Data!B"&201+(ROWS($1:1)-1)*144)=TIME(9,10,0),INDIRECT("Data!A"&344+(ROWS($1:1)-1)*144)=$A5,INDIRECT("Data!B"&344+(ROWS($1:1)-1)*144)=0.375),"Y","N")

    Note that as the column references are part of a literal string they will not change if copied across, so the $ symbol in front of them is not strictly necessary, though it wouldn't matter if they were left in.

    Hope this helps.

    Pete

  12. #12
    Forum Contributor
    Join Date
    08-20-2009
    Location
    Plymouth, England
    MS-Off Ver
    Excel 2013
    Posts
    149

    Re: When dragging a formula in a cell down worksheet move formula "on" 144 cell locations

    Thanks for all your help Pete, works perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. "Worksheet change" not changing cell on other sheet to match target cell "fill".
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-02-2015, 12:02 PM
  2. Replies: 3
    Last Post: 06-05-2015, 01:55 PM
  3. [SOLVED] "button" to move curser to a specific cell based upon formula results in another cell
    By Araise in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-16-2014, 03:21 PM
  4. [SOLVED] Formula Needed to fill multiple cells with "No" when the word "No" is entered into a cell
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-09-2013, 05:36 PM
  5. [SOLVED] If there is any text in column "A$" on "sheet1" then move cell to column "A$" on "sheet2"
    By ckgeary in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2013, 08:28 PM
  6. Replies: 4
    Last Post: 05-20-2013, 02:06 AM
  7. Replies: 8
    Last Post: 01-20-2013, 04:21 PM

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