troubleshooting Question

Excel 2010 VBA - Setting variables and constants.

Avatar of brothertruffle880
brothertruffle880Flag for United States of America asked on
Microsoft Excel
3 Comments1 Solution316 ViewsLast Modified:
I want to set a commission rate of 4% as a constant and when I run my procedure I get the error message  "Object required"  I have no idea what this means.

Dim silver As Double
Set silver = 0.04

Here is my procedure.  It's a simple "learning VBA" example:
(I'm calculating commissions for sales people)
Option Explicit
Dim TotalSales As Currency
Dim CommissionAmt As Currency
Dim Count As Integer



Public Sub Commission()
Dim gold As Double
Set gold = 0.04
Dim silver As Double
Set silver = 0.04
Dim bronze As Double
Set bronze = 0.02
For Count = 1 To 11
TotalSales = Cells(Count, 6).Value
If TotalSales > 10000 Then
CommissionAmt = TotalSales * gold
ElseIf TotalSales > 7000 Then
CommissionAmt = TotalSales * silver
Else
CommissionAmt = TotalSales * bronze
End If
Cells(Count, 7).Value = CommissionAmt
Next Count
End Sub
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros