Subtraction of cell based on condition

Ace71425

Board Regular
Joined
Apr 20, 2015
Messages
130
how do I make this statement work?

Code:
If Range("F11") = "8" And Range("N69") = 20 Then
Lunch = Range("N69") - 30
Range("N66") = Lunch
End If
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
What do you expect it to do when it is working?

A shorter version to the same effect would be

Code:
If Range("F11") = 8 And Range("N69") = 20 Then Range("N66") = -10
 
Upvote 0
I need it where if the value of those first 2 cells match then 30 is subtracted from the current value of the third cell
 
Upvote 0
Try

Code:
If Range("F11") = 8 And Range("N69") = 20 Then Range("N66") = Range("N66") -30

Your original code should also work if you change N69 to N66 in the second line.
 
Upvote 0
That looks solid but it doesnt seem to be working....I have it under the worksheet change event
 
Upvote 0
Are you changing anything in order to trigger the event?
 
Upvote 0
Basically a user enters their hours in F11 and N69 is a field that counts how many minutes theyve worked since they opened the sheet. I need this to account for their lunch so in my example if that field N69 hits 20 after going up every minute 16,17,18,19,20 when it hits 20 if they are working 8 hours indicated in the F11 field I need the N66 to be subtracted by 30 aka their lunch
 
Upvote 0
Does N69 hold a formula, or is it controlled by code?

Please post the formula / code as appropriate.
 
Upvote 0
this is the formula in N69 =ROUNDDOWN(MOD(N64-N65,1)*1440,0) it is like that so I can get a whole number different between 2 date cells
 
Upvote 0
Try using the worksheet calculate event instead of change.
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,850
Members
449,194
Latest member
HellScout

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