# need help!!!

#### Lone Star

##### New Member
Can anyone tell me how to write this formula in Excel?
If D7 is 3 use this formula=SUM(D8*180)+(D9*30)
If D7 is 5 use this formula=SUM(D8*310)+(D9*30)

And what is the name of the formula?

Thanks

### Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

#### Domenic

##### MrExcel MVP
Try...

=IF(D7=3,(D8*180)+(D9*30),IF(D7=5,(D8*310)+(D9*30),""))

Hope this helps!

##### MrExcel MVP
Insert a new sheet and name it Admin.

In A2 enter a name that is descriptive of 30, say, Thirty.
In B2 enter: 30

Name B2 Thirty via the Name Box on the Formula Bar.

In A4 enter: 3
In A5 enter: 5
In B4 enter: 180
In B5 enter: 310

Select A4:B5 and name the selection ConstantTable via the Name Box.

Now invoke...

=D8*VLOOKUP(D7,ConstantTable,2,0)+D9*Thirty

#### respree

##### Active Member
You don't say what you want it to do if D7 is neither 3 or 5.

Assuming you want to display a blank (" ", in this formula), it's:

=IF(D7=3,SUM((+D8*180)+(+D9*30)),IF(D7=5,SUM((+D8*310)+(+D9*30)),""))

Replace the "" for 'whatever you want it to do if neither of the two conditions are met.

#### Lone Star

##### New Member

I think it worked...thanks a bunch what is this called?

#### respree

##### Active Member
The "if" formula.

#### Lone Star

##### New Member
thanks it looks as if all is working well.

Replies
4
Views
313
Replies
3
Views
75
Replies
8
Views
261
Replies
13
Views
468
Replies
4
Views
75

1,136,655
Messages
5,677,015
Members
419,668
Latest member
DharmaK

### 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