Compare two cells and determine one of three actions to return a value

Novice Excel User

New Member
Joined
May 16, 2024
Messages
14
Office Version
  1. 365
Platform
  1. Windows
What I need is a formula to compare the frequency (hourly/weekly) in D8 and D9 and perform one of the following:
  • If D8 is Hourly and D9 is weekly then multiply C15 by E8
  • If D8 is weekly and D8 is hourly then divide C15 by E8
  • If D8 and D9 are the same (both are either hourly or weekly) then return the value in C15 as is
Essentially I need the salary in C15 to reflect the appropriate frequency in order to calculate what the new salary at the correct frequency, either hourly or weekly.

Here's a couple formulas I have tried, but don't seem to work fully:
=IF(AND(G8="hourly", G9="weekly"), F15*H8, IF(AND(G8="weekly", G9="hourly"), F15/H8, F15))
=IFS(D8=D9, C15, AND(D8="Hourly", D9="Weekly"), C15*E8, AND(D8="Weekly", D9="Hourly"), C15/E8)
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
See if this works
Excel Formula:
=IF(AND(D8="hourly", D9="weekly"),C15*E8,IF(AND(D8="weekly", D9="hourly"),C15/E8,IF(OR(AND(D8="hourly", D9="hourly"),AND(D8="weekly", D9="weekly")),C15,"Error")))
 
Upvote 0
Thanks, but this only returns "Error" when I enter it into my spreadsheet, regardless of what the other cells it's looking at have in them. I need to it return a number/salary.
 
Upvote 0
Thanks, but this only returns "Error" when I enter it into my spreadsheet, regardless of what the other cells it's looking at have in them. I need to it return a number/salary.

It returns 'Error' if none of the conditions you specified are true. I had to guess a bit because of inconsistent information in your post. I think you may need to clean up your conditions and re-post. For example, here you say that D8 and D9 are the cells of interests:

What I need is a formula to compare the frequency (hourly/weekly) in D8 and D9 and perform one of the following:
  • If D8 is Hourly and D9 is weekly then multiply C15 by E8
  • If D8 is weekly and D8 is hourly then divide C15 by E8
  • If D8 and D9 are the same (both are either hourly or weekly) then return the value in C15 as is

but then you post formulas that use G8 and G9 , instead of D8 and D9 as you first said.
Here's a couple formulas I have tried, but don't seem to work fully:
=IF(AND(G8="hourly", G9="weekly"), F15*H8, IF(AND(G8="weekly", G9="hourly"), F15/H8, F15))
=IFS(D8=D9, C15, AND(D8="Hourly", D9="Weekly"), C15*E8, AND(D8="Weekly", D9="Hourly"), C15/E8)

Do you think you can revise your requirements to make things consistent?
 
Upvote 0
Not sure if this has any impact but the values in D8 and D9 are based on a vlookup formulas that pull from a table in a separate worksheet within the same workbook. Could the formulas in those fields be impacting the affectedness of this formula?
 
Upvote 0
It should not, but you should use static values for D8 & D9 until you are sure your formula(s) are working. Once they are go back and replace with VLookup and test further.
 
Upvote 0
=IF(AND(D8="hourly",D9="weekly"),C15*H8,IF(AND(D8="weekly",D9="hourly"),C15/H8,IF(D8=G9,C15,"")
This one isn't calculated; it shows the formula in the cell, as if there is no equals sign in front, even though it is (copied and pasted into the spreadsheet).
 
Upvote 0

Forum statistics

Threads
1,223,939
Messages
6,175,533
Members
452,652
Latest member
eduedu

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