Excel/Fuctions Running Automatically
Expert: Richard Roberts - 11/7/2009
QuestionHello I am trying to write a function in VBA to calculate a commission accelerator. I am doing this in VBA because when I write if statements in excel itself it causes a circular reference. I have the function working in VBA when i run it directly, but I am struggling to have the formula run automatically when information is input. Below is a copy of my formula. I appreciate the help.
Public Function Commissions()
Worksheets("Input").Activate
Worksheets("Input").Range("N24").Activate
If (Range("N24") < Range("Y12")) Then Range("R14") = Range("U10") Else
If (Range("N24") > Range("W12")) And (Range("N24") < Range("Y12")) Then Range("R14") = Range("U12") Else
If (Range("N24") > Range("W14")) And (Range("N24") < Range("Y14")) Then Range("R14") = Range("U14") Else
If (Range("N24") > Range("W16")) And (Range("N24") < Range("Y16")) Then Range("R14") = Range("U16") Else
If (Range("N24") > Range("W18")) And (Range("N24") < Range("Y18")) Then Range("R14") = Range("U18") Else
If (Range("N24") > Range("W20")) And Range("N24") < Range("Y20") Then Range("R14") = Range("U20") Else
If (Range("N24") > Range("W22")) Then Range("R14") = Range("U22")
End Function
AnswerEric
I am definately not a VBA expert--while I may be able to figure out an answer for you It won't e very quickly, so I suggest you reask the question of another allexperts person and I'm sure you can get a better and quicker answer.
Sorry I oculdn't be of more help
Richard
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your
Excel question answered in this area then please ask an Excel question here