?
SolvedPrivate

Excel VBA - Type Mismatch Error 13

Posted on 2015-01-30
4
Medium Priority
?
30 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn various types of data validation for different data types in Excel 2013.
Viewers will learn the basics of formula auditing in Excel 2013.

777 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