+ Reply to Thread
Results 1 to 18 of 18

Increment within a formula

  1. #1
    Registered User
    Join Date
    09-03-2008
    Location
    Indiana
    Posts
    10

    Increment within a formula

    I have a formula that I'd like to have increment by one, but I can't figure out how to do it.

    Here's the formula:
    =IF(INDIRECT("'Supervisor'!B"&ROW()-4)="Y",E12-D12,IF(INDIRECT("'Supervisor'!B"&ROW()-4)="N","0",IF(INDIRECT('"Supervisor'!B&ROW()-4)="","0")))

    I'd like to have the -4 in the equation increment to -5 when I paste it to the next row without having to fix each one of them. Any ideas?


  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Replace the 4's with Row($A4)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    If the formula were copied down by rows, and the -4 went to -5, -6, ... as copied, the result would be that it always referred to the same cell.

    BTW, doesn't this give the same result you have now?

    =IF( INDIRECT("'Supervisor'!B" & ROW() - 4) = "Y", E12 - D12, 0)

  4. #4
    Registered User
    Join Date
    09-03-2008
    Location
    Indiana
    Posts
    10

    Kind of works

    Thanks for shortening the expression. Yes, the formula does refer back to the same cell for each row in that section of the spreadsheet, so it needs to stay the same for about 9 rows on the second spreadsheet. When I put the following in,
    =IF(INDIRECT("'Supervisor'!B"&ROW($A4))="Y",E9-D9,"0")

    it appears to work for all rows except when I hit the row that actually matches the row I'm on. For example, if I'm on row 8 in the second spreadsheet, and it needs to look in row 8 on the supervisor spreadsheet, it won't work with a zero. Above row 8, it will need to increment the other direction, so I'm not sure if I need to put a negative sign in the expression when it goes to rows below row 8. Does that make sense?

  5. #5
    Registered User
    Join Date
    09-03-2008
    Location
    Indiana
    Posts
    10

    Update

    Okay, I was wrong, the equation didn't exactly do what I wanted it to do. As I tried the formula on another cell, it appears that the $a4 refers back to cell a4 in the original spreadsheet, but then will increment back to $a3 (or the cell above it) on the row above. I need to keep looking at the same cell, and determine if there is a Y there for a series of about 9 rows. (It would also be fabulous if I could get it to be able to copy those nine rows and then increment that $a4 expression by two to get to the next set to data. That may be too much to ask in one post!!!)

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    You might post a workbook and explain in context.

  7. #7
    Registered User
    Join Date
    09-03-2008
    Location
    Indiana
    Posts
    10

    Attached spreadsheet

    The spreadsheet is attached. Basically, I'd like to use the information in spreadsheet 1 to calculate information in the other spreadsheets, and then be able to add on more samples onto the end of each spreadsheet without having to modify the equations each time a set of rows is added. The rest of the functions appear to work pretty well, but I'm a bit baffled about how to make the other part work. The spreadsheets will be used to track throughput at different stages in a process.
    Attached Files Attached Files
    Last edited by goofymom; 09-15-2008 at 01:38 PM. Reason: Needed to add smalled spreadsheet

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Sorry, I can't tell what you're trying to do -- you skipped the explanation part.

    I can tell you that your workbook would be dramatically improved and easier to operate if you arranged your data in database fashion: identical records with duplicate information duplicated. For example, on the Analyst sheet, the batch number should appear on every row.
    Last edited by shg; 09-15-2008 at 02:37 PM.

  9. #9
    Registered User
    Join Date
    09-03-2008
    Location
    Indiana
    Posts
    10

    Explanation

    I would agree that we would prefer to use a database (like Access) for the data, but will not be able to. We want to be able to control access to each spreadsheet, such that only the supervisor can enter data on the first page and then the analyst enters their information on the second page of the spreadsheet. The spreadsheet could then calculate the time difference between each of the steps (e.g., from the date received on the first page to the date the analyst starts testing on the second page, etc.). We can then track cycle times between each step by subtracting dates between each item and see how long it really takes to test a sample. Does that make it any clearer?

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    I would agree that we would prefer to use a database (like Access) for the data,
    I wasn't suggesting that; just that you organize the data you have like records in a database.

    You have Batch listed, then a bunch of blank cells, then another Batch. Visually, it's clear that the blank cells are all in the last batch above; formula-wise, it's misery. That's what I'm suggesting you correct.

    And I'll be happy to help you with your formula if you will explain what it's supposed to do. All I know now is that it doesn't work.

  11. #11
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    I can just agree with shg, the spreadsheet needs to be updated.
    I would not trust the spreadsheet not to contain any errors.

    Here are a few problems:
    * Formulas are used in the cells instead of used under Conditional formatting, Formula Is.
    ... Each top row should have only one type of formula that can be copied all the way down.
    ... Input values and formulas should (generally) never be mixed in the same column - when the spreadsheet is used as a database.
    ... The headline should tell what's beneath. Supervisor!C11 --> name or 0 or 1
    ... Also the headline Analys initials 'Analyst and 2PV'!C4 --> 0,1,N/A is this an initial?
    * The Indirect formula is used much too often. =VLOOKUP() or INDEX/MATCH should be used instead.
    ... If I input a blank row in sheet supervisor, almost every formula in 'Analyst and 2PV' stops working.
    ... A number of formulas are overly complex and could be simplified/shortened.
    * ...

    The above means extra work and extra risk for errors.

    Here is what I would do:
    * Try to divide each sheets columns into 3 sections: INPUT, CALCULATION and OUTPUT (see encl.)
    * Remove all formulas (in the cells) that are used for conditional formatting and put them under the Conditional formatting, 'Formula Is' instead of 'Cell value is'.
    (see cell 'Analyst and 2PV'!C4 )
    ...I could not understand the logic here so...
    * Learn how to reference values with the use of Vlookup and Index/Match (see the new formulas)
    * Note that col. K, L has been hidden. Mark the column and right click unhide.
    * A new CF (conditional formatting) has been used in col. A

    I started to make some changes but I did not understand the logic behind the conditional formatting so I left that, except for an example of CF in cell 'Analyst and 2PV'!C4.

    Hope this could be a start
    Ola
    Attached Files Attached Files
    Last edited by olasa; 09-15-2008 at 06:02 PM.

  12. #12
    Registered User
    Join Date
    09-03-2008
    Location
    Indiana
    Posts
    10

    Now I'm lost!

    Okay, I'll admit to not being very good with Excel, but you completely lost me now! I'm not sure how you divide up a spreadsheet, etc. I basically need the number of days between the day listed on spreadsheet 1 and the 3 dates on the last page, or combination of the dates on the last page to determine cycle times. Any way to clarify it?

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    get rid of that nasty indirect it just confuses things
    =IF(Supervisor!$B$8="Y",D2-Supervisor!$F$8,IF(Supervisor!$B$8="N","N/A",IF(Supervisor!$B$8="",0,)))
    replaces
    =IF(INDIRECT("'Supervisor'!B"&ROW()+6)="Y",D2-(INDIRECT("'Supervisor'!F"&ROW()+6)),IF(INDIRECT("'Supervisor'!B"&ROW()+6)="N","N/A",IF(INDIRECT('"Supervisor'!B&ROW()+6)="","0")))
    now
    D2-Supervisor!$F$8
    returns 9 days (thats if you have 13/08/08 in d2 and 04/08/08 in Supervisor!$F$8
    Last edited by martindwilson; 09-16-2008 at 11:29 AM.

  14. #14
    Registered User
    Join Date
    09-03-2008
    Location
    Indiana
    Posts
    10

    Only helps a bit

    We originally had the table set up as you stated, however, if I want to copy and add another column, I am forced to update all the $x$ values in the new row, which is what we were trying to avoid in the first place.

  15. #15
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    Ok then ive corrected your original so it works

    Please Login or Register  to view this content.
    this bit was wrong
    Please Login or Register  to view this content.
    but your formula always ref f8 and b8 anyway
    only D changed
    so perhaps
    Please Login or Register  to view this content.
    Last edited by martindwilson; 09-16-2008 at 02:19 PM.

  16. #16
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    Sorry I've made so many changes (see Attached file).

    Requests:
    1. "I basically need the number of days between the day listed on spreadsheet 1 and the 3 dates on the last page, or combination of the dates on the last page to determine cycle times."
    --> See attached formulas on Sheet 2 (red=above target)

    2. "if I want to copy and add another column, I am forced to update all the $x$ values in the new row, which is what we were trying to avoid in the first place. "
    --> With the attached formulas you should be able to add/delete any number of rows/columns.

    Hope this helps at least a bit
    Ola


    Changes made
    * reduced the number of Unique (complex) formulas to 6 ... compare to quite many formulas in the previous file.
    * Applied only 1 Unique conditional formatting rule, in Sheet 1
    * Applied only 2 Unique conditional formatting rules, to Sheet 2
    * Values that exceed targets are automatically colored in red.

    To add?
    * I removed all the black lines from sheet 2, since I wasn't sure what purpose they served and I couldn't quite understand if the rule were that they should be applied to all rows without a date and when stability was Y or N or ""?
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    09-03-2008
    Location
    Indiana
    Posts
    10

    I kind of get it

    I kind of see what you're doing now. The only part I would still have copy issues with is the Vlookup part that refers to the array. It doesn't appear to pull in the values for the receipt date with the current formula, without changing it. Am I missing something?

  18. #18
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    There are only 6 unique (master) formulas and they are all located on sheet 2 and row 6. When something needs to be changed you only need to change the formula in row 6 and then copy the formula all the way down.
    For instance when the Vlookup range needs to be extended (column I and J), change the range in cell I6 and J6 and Copy and Paste special, Formulas - all the way down.
    All 6 formula are designed to be (abled to be) copied all the way down.

    If you get tired of changing the length of range, you could instead Insert, Name, Define the vlookup range; for instance call it Myrange. Then use the name Myrange instead of the range in the 2 formulas. Then when the range has to be extended you only update the range defined by Myrange and not the formula. Note that the defined range can be longer then the actual list.

    Next step in 'simplifing' is to use a more advanced approach of automating thing. The named range can actually be set to automatically detect length of the range. This can be done by a fairly advanced formula. But this is optional. Some would consider that this makes things much more complicated.

    Your question:
    "the array. It doesn't appear to pull in the values for the receipt date with the current formula, without changing it. Am I missing something?"
    I might be missing some here but I wrote two new dates in Italic in sheet 1. They get transfered to sheet 2. And the number of days are then calculated - if the other dates in sheet 2 are there.
    So for that perspective I think the formula works.

    But maybe you meant 'Date of manufacture'? In that case, the simplest would be to use the same formula as for 'Date Received in Laboratory' to transfere 'Date of manufacture' to sheet2.

    I hope it helped a bit more
    Ola
    Attached Files Attached Files

+ 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. Formula for bond price
    By Dracan in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-15-2014, 11:17 AM
  2. Replies: 5
    Last Post: 01-28-2009, 06:15 PM
  3. Formula needed to tell me if a value exists
    By WhatF in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-10-2008, 08:16 AM
  4. Conditional formula question
    By odditie in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-27-2007, 09:47 PM
  5. use cell content as cell address in formula
    By nnsc in forum Excel General
    Replies: 4
    Last Post: 11-05-2006, 03:12 AM

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