SolvedPrivate

Excel VBA - Type Mismatch Error 13

Posted on 2015-01-30
4
25 Views
Last Modified: 2016-02-10
Hello EE Experts-

The attached file contains a table that calculates monthly utility bills using a subroutine. The calculation considers the usage multiplied by the rate. The 12 months of bills for each customer are calculated using VBA and the result is dumped in column P in Account worksheet (The tariff information is in the Tariff Schedule). I use a series of range statements to help the code move through the table.

For some reason, the routine will go through 83 rows and then quit with the Type Mismatch Error 13. I can't figure out what is causing the error.

Any thoughts?

Regards,
T-
0
Comment
Question by:TCristiano
  • 2
4 Comments
 
LVL 13

Expert Comment

by:akb
ID: 40581174
Attachment??
0
 

Author Comment

by:TCristiano
ID: 40581446
0
 
LVL 15

Accepted Solution

by:
ChloesDad earned 500 total points
ID: 40581648
Final_Bill is not defined in the subroutine, so ends up as a string value "7.0246.8" so you can't do the + operation
The error is in the multi code lines where you use an & instead of a + at the end of each line

Case Is <= Threshold4
final_bill = (Threshold1 * Rates1) + (Threshold2 - Threshold1) * Rates2 + _
             (Threshold3 - Threshold2) * Rates3 + (Usage - Threshold3) * Rates4 + final_bill

Case Is <= Threshold5
final_bill = (Threshold1 * Rates1) + (Threshold2 - Threshold1) * Rates2 + _
             (Threshold3 - Threshold2) * Rates3 + (Threshold4 - Threshold3) * Rates4 + _
             (Usage - Threshold4) * Rates5 + final_bill
Case Else
final_bill = (Threshold1 * Rates1) + (Threshold2 - Threshold1) * Rates2 + _
             (Threshold3 - Threshold2) * Rates3 + (Threshold4 - Threshold3) * Rates4 + _
             (Threshold5 - Threshold4) * Rates5 + (Usage - Threshold5) * Rates6 + final_bill

Open in new window

0
 

Author Closing Comment

by:TCristiano
ID: 40582974
Brilliant! Thanks for the quick response!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Macro 6 49
COPY from excel to notepad 3 35
Merging-Splitting-Multiple-Rows 33 42
Run-time error 429 - ActiveX Component Can't Create Object - VBA Code - MS Access - Adobe 4 21
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Viewers will learn a basic relationship technique in Power Pivot for Excel 2013.
Viewers will learn the basics of the new Quick Analysis feature in Excel 2013.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now