Hi,
I need to automate some data entry since I have a huge database in the following form:
The A column contains the sample number. Each row has a sample so from A1 and downwards its just
1
2
3
...
k
The B column contains the number of observations in each sample . Importantly, some samples has no observations at all, so n=0 in some cases.
The C column contains the average value or estimate for each sample. When there are no observations in the sample, the corresponding estimate in the C column is blank.
I have reason to believe that when n=0, the best estimate for this sample is the average of the estimate in the row above and the row below. So I did a formula in the D column: =IF(B3=0;AVERAGE(C2;C4);0) and copied down to the end. The I took =SUM(C3:D3) in the E column and copied down. This would work just fine if it wasn't for the fact that it quite often are several samples without observations in a row. So I need a more general method. For example:
A B C D E
1 1 10 "" 10
2 0 "" 8 8
3 1 6 0 6
4 0 "" 6 6
5 0 "" 2 2
6 1 2 0 2
7 0 "" 2 2
8 0 "" #DIV/0! #DIV/0!
9 0 "" 1 1
10 1 1 0 1
The result above is insufficient. The result I'm looking for is rather
A B C D E
1 1 10 "" 10
2 0 "" 8 8
3 1 6 0 6
4 0 "" 4 4
5 0 "" 4 4
6 1 2 0 2
7 0 "" 1.5 1.5
8 0 "" 1.5 1.5
9 0 "" 1.5 1.5
10 1 1 0 1
So both E4 and E5 should be the average of E3 and E6 while E7, E8 and E9 should each be the average of E6 and E10. More than 10 blanks is very rare so the proposed method doesn't have to be applicable to larger gaps than that. Please tell me if I'm being unclear, and thanks for helping!
Sincerely
Aqil
I need to automate some data entry since I have a huge database in the following form:
The A column contains the sample number. Each row has a sample so from A1 and downwards its just
1
2
3
...
k
The B column contains the number of observations in each sample . Importantly, some samples has no observations at all, so n=0 in some cases.
The C column contains the average value or estimate for each sample. When there are no observations in the sample, the corresponding estimate in the C column is blank.
I have reason to believe that when n=0, the best estimate for this sample is the average of the estimate in the row above and the row below. So I did a formula in the D column: =IF(B3=0;AVERAGE(C2;C4);0) and copied down to the end. The I took =SUM(C3:D3) in the E column and copied down. This would work just fine if it wasn't for the fact that it quite often are several samples without observations in a row. So I need a more general method. For example:
A B C D E
1 1 10 "" 10
2 0 "" 8 8
3 1 6 0 6
4 0 "" 6 6
5 0 "" 2 2
6 1 2 0 2
7 0 "" 2 2
8 0 "" #DIV/0! #DIV/0!
9 0 "" 1 1
10 1 1 0 1
The result above is insufficient. The result I'm looking for is rather
A B C D E
1 1 10 "" 10
2 0 "" 8 8
3 1 6 0 6
4 0 "" 4 4
5 0 "" 4 4
6 1 2 0 2
7 0 "" 1.5 1.5
8 0 "" 1.5 1.5
9 0 "" 1.5 1.5
10 1 1 0 1
So both E4 and E5 should be the average of E3 and E6 while E7, E8 and E9 should each be the average of E6 and E10. More than 10 blanks is very rare so the proposed method doesn't have to be applicable to larger gaps than that. Please tell me if I'm being unclear, and thanks for helping!
Sincerely
Aqil