View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Todd Huttenstine[_2_] Todd Huttenstine[_2_] is offline
external usenet poster
 
Posts: 237
Default Creating a function

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