SolvedPrivate

Excel VBA - Type Mismatch Error 13

Posted on 2015-01-30
4
27 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Video by: Zack
Viewers will learn about various customizable options in Excel 2013.
Viewers will learn a basic relationship technique in Power Pivot for Excel 2013.

856 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