You are here:

Excel/Fuctions Running Automatically

Advertisement


Question
Hello 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

Answer
Eric

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

All Answers

Answers by Expert:


Ask Experts

Volunteer


Richard Roberts

Expertise

Can assist you in most areas of Excel, have been working with it for about 15 years in many types of applications, but primarily in financial and accounting applications. I am a CPA and many client or client problems have necessitated the use of excel. I am not an expert in charting, macros, or pivot tables.

Experience

Have been working with Excel for about 15 years primarily in accounting and financial areas.

Education/Credentials
BA, CPA

©2009 About.com, a part of The New York Times Company. All rights reserved.