# What formula/function should I use?

#### Shmeetbag

##### Board Regular
What formula/function should I use?

I have tried Vlookup and IF functions but can’t seem to get this to work.
In column A1:A50 there will be a number imputed in random places. I need the sum of area B1:C50 between the numbers in column A returned in column D on the same row as the number in column A.

A1=3 B1=20 C1=5 D1=35
A2=””B2=10 C2=”” D2=””
A3=5 B3=””C3=10 D3=50
A4=”” B4=”” C4=30 D4=””
A5=”” B5=10 C5=”” D5=””
A6=”” B6=”” C6=”” D6=””
A7=8 B7=1 C7=””D7=1
A8=11 B8=12 C8=”” D8=12

3 is imputed in column A1 and returns 35 in D1 (20+10+5). 5 is imputed in A3 and returns 50 in D3 (10+30+10).

Thanks

### Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the \$ sign).

=A1*C1+B1

#### Shmeetbag

##### Board Regular
That won't work because the formula needs to sum the numbers in the range B1:C50. The order of the numbers in column A will have a different number of spaces in between them as well as different imputs in the range of B1:C50.

#### barry houdini

##### MrExcel MVP
Not the prettiest way perhaps...

in D1

=IF(A1,SUM(B1:INDEX(C1:C\$100,IF(ISNA(MATCH(TRUE,INDEX(A2:A\$100<>0,0),0)),ROWS(A2:A\$100),MATCH(TRUE,INDEX(A2:A\$100<>0,0),0)))),"")

copied down column

assumes you have up to 100 rows, if you have more then adjust ranges accordingly

#### Zack Barresse

##### MrExcel MVP
Following your logic in your first post, I don't follow how my formula will not suit. Maybe if you could post more info or 10-20 rows of example data with the HTML Maker..

#### Shmeetbag

##### Board Regular
Works great! Thanks for the help.

#### Shmeetbag

##### Board Regular
A slight problem

The formula works, but if I have a formula in column A, it does not work. When I type in a number it will work fine. For some reason this formula cannot read from column A when it has a formula in it. How could I get around that??

=IF(A1,SUM(B1:INDEX(C1:C\$100,IF(ISNA(MATCH(TRUE,INDEX(A2:A\$100<>0,0),0)),ROWS(A2:A\$100),MATCH(TRUE,INDEX(A2:A\$100<>0,0),0)))),"")

Thanks

#### barry houdini

##### MrExcel MVP
What would the formula be? what do you get in the cell if not a number?

if you have a formula which gives you either a number or "" perhaps

=IF(ISNUMBER(A1),SUM(B1:INDEX(C1:C\$100,IF(ISNA(MATCH(TRUE,INDEX(A2:A\$100<>0,0),0)),ROWS(A2:A\$100),MATCH(TRUE,INDEX(A2:A\$100<>0,0),0)))),"")

#### Shmeetbag

##### Board Regular
If any formula is in the cell it does not work. The error is #value!. It does return a value only in the row with the input in column A, but the incorrect number.

#### barry houdini

##### MrExcel MVP
Having formulas in column A won't make any difference per se but it may affect how my proposed formula works, depending on what results those formula return, if they return text values you may get an error.

Did you try the revised formula I posted above?

What formula is in column A?

Replies
2
Views
212
Replies
4
Views
219
Replies
0
Views
167
Replies
15
Views
210
Replies
10
Views
500

### Forum statistics

1,195,939
Messages
6,012,420
Members
441,698
Latest member
DaveTeo ### 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.

### Which adblocker are you using?    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

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