SolvedPrivate

Excel VBA - Type Mismatch Error 13

Posted on 2015-01-30
4
24 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
Comment Utility
Attachment??
0
 

Author Comment

by:TCristiano
Comment Utility
0
 
LVL 15

Accepted Solution

by:
ChloesDad earned 500 total points
Comment Utility
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
Comment Utility
Brilliant! Thanks for the quick response!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
vb6 connector to mongodb 2 25
VBA to Copy a worksheet to another workbook 3 56
Spell Check in VB6 13 41
TT Add New Entry 13 28
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Viewers will learn how to create a PivotTable and make basic changes to it in Excel 2013.
Viewers will learn the basics of printing in Excel 2013 and how to adjust some common settings.

771 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

9 Experts available now in Live!

Get 1:1 Help Now