Adding a worksheet function

Jook

New Member
Joined
Mar 19, 2002
Messages
22
I have added the function below to the workbook level of my VBA

Function Mileage(CostCentre)
' Checks for employees cost centre and subs correct one
Select Case CostCentre
Case "120.": Mileage = "130."
Case "220.": Mileage = "230."
Case "125.": Mileage = "130."
Case "225.": Mileage = "230."
Case "150.": Mileage = "140."
Case "250.": Mileage = "240."
End Select
End Function


The problem is that when I enter =Mileage(B4) in a cell, where B4 is the test valve, it returns #name? I have entered a simple function like:

Function user(user As String)
user = Application.UserName
End Function

And when I enter =User() in the cell I get #name? instead of my own name.

Any one know what I am doing wrong?

Thanks for any help.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Jook

New Member
Joined
Mar 19, 2002
Messages
22
Thanks

I knew it had to be something simple like that. That is the way it always is.
 

Forum statistics

Threads
1,181,530
Messages
5,930,426
Members
436,738
Latest member
JFry

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
Top