View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Creating a function

Todd,

That probably means that you don't have a number in A1.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine" wrote in message
...
When I do that Im getting #VALUE error


-----Original Message-----
Todd,

If you want to put the function in A1, it cannot use a

value in A1, that's
a circular reference. A function in a cell can only

reference another cell.
SO if you want to pick up SalesQ from a cell, the

function would look like
this

Public Function CalComm(SalesQ) As Currency
CalComm = SalesQ * (1.5 / 100)
End Function

and if A1 held the SalesQ figure, the function would go

in A2 or some other
cell and would look like

=CalComm(A1)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine"

wrote in message
...
Ah there we go, thank you. I had it in the worksheet
module. I put it in a regular module and now its in

User
Defined, however when I try to insert it in cell A1, it
does nothing. when I am inserting it in cell A1 it says
this function takes no arguments. So how would I make

it
take argument so that whatever is in cell A1, it will

use
that value as the variable instead of the input box?


-----Original Message-----
Todd,

Where have you stored it? It should be in a general
module, not a worksheet
module or ThisWorkbook.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Todd Huttenstine"


wrote in message
...
Below is a function I am working with to calculate
commissions. How do I get it to where when I click

on a
cell in Excel, and then go to insert function, how

do I
make it to where I can select that function from in
there? Right now I dont see it in there.

Option Explicit
Dim SalesQ As Currency
Dim CalculateCommission As Currency
Public Function CalComm() As Currency
CalculateCommission = SalesQ * (1.5 / 100)
End Function

Public Sub main()
SalesQ = InputBox("Enter Sales Amount")
Call CalComm
MsgBox ("The commission amount is: $" &
CalculateCommission)
End Sub



.



.