ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   If statement (https://www.excelbanter.com/new-users-excel/143114-if-statement.html)

robertm600635

If statement
 
I'm trying to use "IF" to do a calculation. What I need to do is run one of
two calculations based on the contents of a cell. Example: If A1="Salary"
Sum(B1*12). If A1="Hourly" Sum(B1*2080). A1 is always going to be either
Salary or Hourly and B1 is the rate of Pay. This is to calculate an annual
salary. Please help

Niek Otten

If statement
 
=IF(A1="Hourly",B1*12,B1*2080)

Or, slightly shorter

=B1*IF(IfA1="Hourly",12,2080)

Note that you don't need SUM

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


"robertm600635" wrote in message
...
| I'm trying to use "IF" to do a calculation. What I need to do is run one of
| two calculations based on the contents of a cell. Example: If A1="Salary"
| Sum(B1*12). If A1="Hourly" Sum(B1*2080). A1 is always going to be either
| Salary or Hourly and B1 is the rate of Pay. This is to calculate an annual
| salary. Please help



Gary''s Student

If statement
 
No IFs are needed:

=((A1="Hourly")*2080+(A1="Salary")*12)*B1

--
Gary''s Student - gsnu200722


All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com