#NAME? Error

iaindowner

New Member
Joined
Aug 12, 2014
Messages
18
I need to create a formula which will work out the length of a shift which is written in the following format: 9-5 or 10.30-6 or 5-CL (CL standing for close). I have all the steps in place but when I try and combine all the steps into one formula the #Name? error shows.

Close Time

<tbody>
</tbody>
12AM

<tbody>
</tbody>
12AM

<tbody>
</tbody>
Close

<tbody>
</tbody>
12

<tbody>
</tbody>
=LEFT(B2,(IF(LEN(B2)=3,1,2)))

<tbody>
</tbody>
Shift

<tbody>
</tbody>
11.30-6

<tbody>
</tbody>
11.30-6

<tbody>
</tbody>
Length

<tbody>
</tbody>
7

<tbody>
</tbody>
=LEN(B4)

<tbody>
</tbody>
Position of -

<tbody>
</tbody>
6

<tbody>
</tbody>
=SEARCH("-",B4)

<tbody>
</tbody>
Start Time

<tbody>
</tbody>
11.30

<tbody>
</tbody>
=LEFT(B4,B6-1)

<tbody>
</tbody>
End Time

<tbody>
</tbody>
6

<tbody>
</tbody>
=IF(ISNUMBER(SEARCH("CL",B4,1)),B3,RIGHT(B4,B5-B6))

<tbody>
</tbody>
Start Time

<tbody>
</tbody>
11.5

<tbody>
</tbody>
=1*IF(ISNUMBER(SEARCH(".",B7,1)),RIGHT(B7,2)/60+LEFT(B7,2),B7)

<tbody>
</tbody>
End Time

<tbody>
</tbody>
6

<tbody>
</tbody>
=1*IF(ISNUMBER(SEARCH(".",B8,1)),RIGHT(B8,2)/60+LEFT(B8,2),B8)

<tbody>
</tbody>
Shift Length

<tbody>
</tbody>
6.5

<tbody>
</tbody>
=IF(B9>B10,12-B9+B10,B10-B9)

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hey iaindowner,

Microsoft says:

Correct a #NAME? error

Occurs when Microsoft Excel doesn't recognize text in a formula.

You provided the formulas which I plugged into a sample worksheet and came up with multiple errors. Column B is what you said you had for results and Column C is the results that I got. I am not sure if I plugged in the formulas in the correct place as you did not include Row/Column information as I have in this example.

ABCD
1Close Time12am12am

<tbody>
</tbody>
2Close1212LEFT(B2,(IF(LEN(B2)=3,1,2)))
3Shift11.30-611.30-6

<tbody>
</tbody>
4Length71
LEN(B4)

<tbody>
</tbody>

<tbody>
</tbody>
5Positon of -6#VALUE!
SEARCH("-",B4)

<tbody>
</tbody>

<tbody>
</tbody>
6Start Time11.37
LEFT(B4,B6-1)

<tbody>
</tbody>

<tbody>
</tbody>
7End Time6#VALUE!
IF(ISNUMBER(SEARCH("CL",B4,1)),B3,RIGHT(B4,B5-B6))

<tbody>
</tbody>

<tbody>
</tbody>
8Start Time11.56
1*IF(ISNUMBER(SEARCH(".",B7,1)),RIGHT(B7,2)/60+LEFT(B7,2),B7)

<tbody>
</tbody>

<tbody>
</tbody>
9End Time611.00833
1*IF(ISNUMBER(SEARCH(".",B8,1)),RIGHT(B8,2)/60+LEFT(B8,2),B8)

<tbody>
</tbody>
10Shift Length6.50.5
IF(B9>B10,12-B9+B10, B10-B9)

<tbody>
</tbody>
11

<tbody>
</tbody>
It may be helpful if you indicate what your starting value(s) are, what you want to happen with the data you input (step by step) and what your end result should be. VBA code may be more efficient as well if you are able to use it (Macro).

later

Ty
 
Upvote 0
6046806796962863602
Please see the picture. The cells I edit are B2 and B4. B2 will contain anything from 12AM to 6AM and B4 will contain e.g. 9-5, 10.30-6, 4-CL.
 
Upvote 0
6046806796962863602
Please see the picture. The cells I edit are B2 and B4. B2 will contain anything from 12AM to 6AM and B4 will contain e.g. 9-5, 10.30-6, 4-CL.

Hey iaindowner,

Well as I am still getting those two Value errors then I guess we are at an impass at the moment.

I will attempt to try and make some sense of it as follows:
1) you want to enter a start time and end time in one cell.
2) you want to do so in the format of 11, 11.30 (numbers after the "." range from 1-59 to indicate minutes), CL which indicates the closing time of 12am
3) you can use helper cells to help strip out unecessary information such as "-", and to change text such as "CL" into readable data.
4) you then want to calculate the time between the start and stop times.
5) you finally want to display the length of the shift in a Hours:Minutes format.

let me know if I am close.

later

Ty
 
Upvote 0
Spot on apart from I need the Length of Shift to appear in an hours format e.g. 10h30m to appear as 10.5

I ideally need the whole formula to be contained in one formula as I want to be able to drag and autofill for all 7 days and 40 staff.

When I replace the cell references in C11 in the picture previously attached with the respective formulas I receive the error.
 
Upvote 0
Hey iaindowner,

Okay so then you will need to have a translater to translate Hours and Minutes into Decimal Hours.

I will take a crack at it when I get back from the store. Is VBA code/Macros an option?

later

Ty
 
Upvote 0
Yes VBA is an option however my knowledge of VBA is limited and the stuff I have done in the past has taken a lot of help. As far as I can see I have done all the steps correctly and the formulae work when all the information is split into seperate cells but when I try and combine the formulae into on formula I get the error.

Thanks.
 
Upvote 0
Hey iaindowner,

Okay great. So at least we know that is an option in the event we can't figure this out.

I was thinking earlier that maybe this has to be an array formula but I am still working the combining it into one formula. I don't think so though.

Well as my math teacher always told me ... Pay attention to the parenthesis. Those operations are done first. So I will give it a try this evening and let you know how I do tomorrow morning. Who knows, maybe I will have
it solved.

later

Ty
 
Upvote 0
Hey iaindowner,

So I worked on this thing for about 5 hours last night and I am not able to get it either.. Maybe it is just that the formula is two complex to be in one cell since it appears to need some helper cells.

There is a lot of searching using the search, len, Left, and Right functions which seems to bog it down. So I see that you have a couple options: One is to get rid of the need for all of that by having two input cells - one for start time and one for stop time. Later you can concatenate them together on a seperate sheet. Two is to create a UDF or macro to do it so you can have variables and references to text and be able to strip the stuff down easier.

I still am having issues with getting all of the single formulas to work so I will have to start from scratch. Since you haven't shown anything I am expecting that your end result will look something like this:
ABCDEFGHI
1EmployeeSunMonTueWedThuFriSatTotal Hours
2Tom8.30-CL
3.5
5-9
4
12-2.15
2.25
9.75
3Betty
4Rick
5

<tbody>
</tbody>
One of the issues that I see is the differentiating between am and pm hours.
later

Ty
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,375
Members
449,155
Latest member
ravioli44

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