Find Delay…

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Using Excel 2010
Hello,

Here is example of 30 rows from C6:P35 every week will be added 1 row below 35….

I want VBA or formula 3 row below of the last data row fid delay of 1, X and 2 signs…in this example T1 has delay for 1=0, for X=1 and for 2=2…. example T2 has delay for 1=6, for X=0 and for 2=1….and so on for T3 to T14.

Note:--1st formula can set find delay max 24 draw back from 0, 2nd always 3 row below of the last data row.

Find Delay.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZ
4
5T1T2T3T4T5T6T7T8T9T10T11T12T13T14
630XX222X112XX221
729X2211X11112X11
828X122221121211X
92711111XX1X2X221
102611211112111211
11251X1X1211X21221
1224112111112111X1
13231X11121X112211
1422X1X1XX21121211Here is example of 30 rows from C6:P35 every week will be added 1 row below 35…. I want VBA or formula 3 row below of the last data row fid delay of 1, X and 2 signs…in this example T1 has delay for 1=0, for X=1 and for 2=2…. example T2 has delay for 1=6, for X=0 and for 2=1….and so on for T3 to T14. Note:--1st formula can set find delay max 24 draw back from 0, 2nd always 3 row below of the last data row.
15211XX21X2XX12221
1620XX21X2111X2212
1719221X22211X1211
18182XX1X1X2X12121
1917X2X11X11X112X2
20151XX221X1X22211
2114XX222X112XX221
2213X2211X11112X11
2312X122221121211X
241111111XX1X2X221
251011211112111211
2691X1X1211X21221
278112111112111X1
2871X11121X112211
296X1X1XX21121211
3051XX21X2XX12221
314XX21X2111X2212
323221X22211X1211
3322XX1X1X2X12121
341X2X11X11X112X2
3501XX221X1X22211
36
37
38T1T2T3T4T5T6T7T8T9T10T11T12T13T14
39Delay106311010311200
40DelayX10032105031113112
41Delay221400332800021
Delay-1X2


Regards,
Moti
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
In C39
Excel Formula:
=MAX(IF(C$1:C$38<>"", ROW(C$1:C$38),""))-MAX(IF(C$1:C$38=$B39, ROW(C$1:C$38),""))
Need to be confirmed using the combination Contr-Shift-Enter
Then copy to the bottom and to the right

Try...
 
Upvote 0
In C39
Excel Formula:
=MAX(IF(C$1:C$38<>"", ROW(C$1:C$38),""))-MAX(IF(C$1:C$38=$B39, ROW(C$1:C$38),""))
Need to be confirmed using the combination Contr-Shift-Enter
Then copy to the bottom and to the right

Try...
Hello Anthony47, yes it worked fine. I changed the range…

VBA Code:
This
=MAX(IF(C$1:C$38<>"", ROW(C$1:C$38),""))-MAX(IF(C$1:C$38=$B39, ROW(C$1:C$38),""))

To this…
=MAX(IF(C$6:C$35<>"", ROW(C$6:C$35),""))-MAX(IF(C$6:C$35=$B39, ROW(C$6:C$35),""))

Just to get result as I wanted…

Is there any way this formula can be converting in VBA and change the range as new row is added below. For example at present range is set 6:35 when row 36 entered it change 6:36 and give the result 3 row below…and after row 37 entered it change 6:37 and give the result always 3 row below the data range….

Thank you for your help.

Kind regards,
Moti :)
 
Upvote 0
I used C$1:C$38 just to allow you to "Insert" new lines as necessary: since they would be added before line 38 the formula will resize automatically and become C$1:C$39, C$1:C$40, etc
 
Upvote 0
I used C$1:C$38 just to allow you to "Insert" new lines as necessary: since they would be added before line 38 the formula will resize automatically and become C$1:C$39, C$1:C$40, etc
Yes I noticed that but it gives me +3 result where is 0 it give 3, and where is 6 it gives 9 that is why I changed.

I guess only the solution could be VBA when I add new row below 35 VBA delete the these 3 result row and find last row and adjust the formula 3 row below adding till last row data may be..
 
Upvote 0
Are lines 36 to 38 empty? (no formulas, no spaces, no hidden characters)
This is what I get:
Cartel2
ABCDEFGH
296X1X1XX
3051XX21X
314XX21X2
323221X22
3322XX1X1
341X2X11X
3501XX221
36
37
38
39Delay1063110
40x100321
412214003
42
43
44
45
Foglio2
Cell Formulas
RangeFormula
C39:H41C39=MAX(IF(C$1:C$38<>"", ROW(C$1:C$38),""))-MAX(IF(C$1:C$38=$B39, ROW(C$1:C$38),""))
 
Upvote 0
Are lines 36 to 38 empty? (no formulas, no spaces, no hidden characters)
This is what I get:
Cartel2
ABCDEFGH
296X1X1XX
3051XX21X
314XX21X2
323221X22
3322XX1X1
341X2X11X
3501XX221
36
37
38
39Delay1063110
40x100321
412214003
42
43
44
45
Foglio2
Cell Formulas
RangeFormula
C39:H41C39=MAX(IF(C$1:C$38<>"", ROW(C$1:C$38),""))-MAX(IF(C$1:C$38=$B39, ROW(C$1:C$38),""))
Ok I understand because you cleared row 38 headers in this case yes your formula is perfect. I must have noticed sorry for it.

Now what if I add every week 1 row below the row 35 100 weeks 100 rows how could be managed this situation? As every time I want result 3 rows below the data.
 
Upvote 0
If line 38 is to contain the headers then use C$1:C$37, and add as many lines you need before line 37
 
Upvote 0
Solution
If line 38 is to contain the headers then use C$1:C$37, and add as many lines you need before line 37
Yes now understood changing so result is correct. In this case when I want to add data below row 35 I need to insert line before adding data to extend the data range is it right?

This affect my next columns data are longer it lives a space between in that. Which, I did not mention it is my fault. I have to think how can I manage?
 
Upvote 0
Using C$1:C$37 you may fit new data in rows and the formula will still return the correct answer; but if you need to add more that 2 lines of new data then you should work by first inserting the new line and then writing the new data.
If you want to make space only in columns A:P (without changing the content of subsequent columns) then you have to use the command "Insert Cells": select Ax:Px (where x is the line before the headers (before the results) and the Menu /Home /Insert (group Cells), Cells
You can obtain the result with the following macro:
VBA Code:
Sub AddLine()
    Range("A1").End(xlDown).Offset(-2, 0).Range("A1:P1").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub
This assumes column A is empty until the cell containing "Delay"
 
Upvote 1

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top