View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default Creating a function

Just a note, and a guess. Make sure the variable of the answer is the same
name as your function. It appears that you keep changing them.

In your function, "CalComm" and "CalculateCommission" are different names.

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



For example,

Public Function CalComm(SalesQ) As Currency
CalComm = SalesQ * 0.015 '(1.5%)
End Function


Just thought I'd mention it in case you didn't catch it from the other
posts.
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Todd Huttenstine" wrote in message
...
Se what I want is to where I can insert that function in
cell A2 and reference cell A1 where the number is. Then
when I click the OK button after I select cell A1 (or
whatever cell I want to reference), I want the answer to
be put in the cell where I inserted the function(in this
case it would be cell A2.).

using the below code..., when I run sub main, it uses an
input box and gives me the correct answer, but instead of
using an input box, I would rather just make it like any
other function where I reference cells.

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

Thanx

Todd Huttenstine