Trying to make formula ignore text

thatguydj

New Member
Joined
Apr 30, 2022
Messages
2
Hello I'm working on making a calculator to calculate hours in a schedule. I want any boxes without numbers to just say "OFF" for employees, but I am having issues with making excel ignore that text.

1651334880958.png


I'm not amazing at functions, but I have the whole schedule working except for the words. There is a second portion of the schedule that subtracts break time from total hours, in case the second value looks confusing. It is lower in the list. Does anyone have any ideas to make the formula ignore the word "OFF"?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
One solution is to enclose every cell reference with the N function. This will return the number if it's a number, and return 0 if it's text.

By the way you do not need the SUM function for what you are doing. You can just remove it.

$scratch.xlsm
ABCDE
1SundayMondayTotal Hours
21:00 PM5:00 PMOFFOFF4
Sheet11
Cell Formulas
RangeFormula
E2E2=((N(B2)-N(A2))+(N(D2)-N(C2)))*24
 
Upvote 0
Here is a much better way.

If you use a cell in an arithmetic expression, and that cell has text, it will cause a #VALUE error. But if you use only SUM, it will be ignored. Your original formula used SUM but it also used an arithmetic expression inside SUM. If we use only SUM with no arithmetic, it works.

Note that the leap of logic here is that we can SUM all of the ending times and subtract the SUM of all the beginning times. You do not have to calculate each day separately.

You will have to add the bit about row 59 similarly.

$scratch.xlsm
ABCDEFGHIJKLMNO
1SundayMondayTuesdayWednesdayThursdayFridaySaturdayTotal Hours
21:00 PM5:00 PM1:00 PM5:00 PMOFFOff1:00 PM5:00 PM1:00 PM5:00 PMOFFOFF1:00 PM5:00 PM20
Sheet11
Cell Formulas
RangeFormula
O2O2=24*(SUM(N2,L2,J2,H2,F2,D2,B2)-SUM(M2,K2,I2,G2,E2,C2,A2))
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,734
Members
449,094
Latest member
dsharae57

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