Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-20-2012, 04:27 AM
hanvyj hanvyj is offline Checking n cells above's content Windows XP Checking n cells above's content Office 2003
Advanced Beginner
Checking n cells above's content
 
Join Date: Feb 2012
Posts: 33
hanvyj is on a distinguished road
Default Checking n cells above's content

I have a function that is a "delay" trigger, at the moment it looks in two columns and when it finds an increase it goes from 0 to 1. It also checks if the three cell above is one, and stays so 1 for 3 cells:



=IF(P23>P22,1,IF(O22=1,IF(AND(O21=1,O20=1,O19=0),0 ,1),0))

So the formula checks if the P column is increasing, if so sets to 1.
If the above value is 1 (column O), it is sets to 1 unless there have been 3 consecutive 1s, in which case its sets to 0 (ie the cells above are 1,1,1,0)

Now, the ammount of consecutive ones it checks at the moment is hard-coded. I'd like to have a cell to specify this but I can't think of a way of doing it.

Can anyone help?
Reply With Quote
  #2  
Old 03-20-2012, 06:04 AM
hanvyj hanvyj is offline Checking n cells above's content Windows XP Checking n cells above's content Office 2003
Advanced Beginner
Checking n cells above's content
 
Join Date: Feb 2012
Posts: 33
hanvyj is on a distinguished road
Default

Is it possible to say reference a cell based on a value say: "O22 + n" where n=2 would reference O24?
Reply With Quote
  #3  
Old 03-21-2012, 09:40 AM
Catalin.B Catalin.B is offline Checking n cells above's content Windows Vista Checking n cells above's content Office 2010 32bit
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

The formula you posted had some errors, i used this:
=IF(AND(P23>P22;SUM(O19:O22)<4);1;0) (for 4 consecutive rows)
To have in a cell the number of consecutive rows with 1 value, You must use sum with offset to accomplish that.
Assuming that in cell M3 you enter the number of consecutive rows with 1 value:
=IF(AND(P23>P22;SUM(OFFSET(O23;-$M$3;0;$M$3;1))<M$3);1;0) . Copy this down. (you must replace formula separators ; to ,)
In this case, OFFSET function creates a range of 1 column, with the number of rows = M3, placed above O23(that is the number of rows above O23: -$M$3)
Reply With Quote
  #4  
Old 03-22-2012, 02:53 AM
hanvyj hanvyj is offline Checking n cells above's content Windows XP Checking n cells above's content Office 2003
Advanced Beginner
Checking n cells above's content
 
Join Date: Feb 2012
Posts: 33
hanvyj is on a distinguished road
Default

Quote:
Originally Posted by Catalin.B View Post
The formula you posted had some errors, i used this:
=IF(AND(P23>P22;SUM(O19:O22)<4);1;0) (for 4 consecutive rows)
To have in a cell the number of consecutive rows with 1 value, You must use sum with offset to accomplish that.
Assuming that in cell M3 you enter the number of consecutive rows with 1 value:
=IF(AND(P23>P22;SUM(OFFSET(O23;-$M$3;0;$M$3;1))<M$3);1;0) . Copy this down. (you must replace formula separators ; to ,)
In this case, OFFSET function creates a range of 1 column, with the number of rows = M3, placed above O23(that is the number of rows above O23: -$M$3)
Thank you, offset was what I needed. I'd worked out I would have to use something like sum. It would also need a check that the top value = 0, otherwise sequences like:

1
0
1
1

would be picked up as "3 in a row" and it would set to 0, so a simple AND(SUM(the n above offset)=n-1,n above = 0) works well

Cheers! I'm sure I'll probably be using Offset a lot more, you sure do learn a lot about excel coming across these tricky problems.
Reply With Quote
  #5  
Old 03-22-2012, 03:58 AM
Catalin.B Catalin.B is offline Checking n cells above's content Windows Vista Checking n cells above's content Office 2010 32bit
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

Great! Then you can mark your thread as solved (under thread tools, select-mark this thread as solved)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking n cells above's content Multiple VLOOKUP's checking multiple Cells OTPM Excel 11 05-23-2011 11:18 AM
Checking n cells above's content Help with checking available times Deepy Excel 1 02-14-2011 05:06 PM
Count range cells eliminating merge cells danbenedek Excel 0 06-15-2010 12:40 AM
Checking for DOS executions ajetrumpet Excel 0 12-06-2009 02:33 PM
Package for CD with links to Windows media player content and Flash Shockwave content hectorh PowerPoint 4 10-15-2009 12:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft