• Status: Solved
  • Priority: Medium
  • Security: Private
  • Views: 33
  • Last Modified:

Excel VBA - Type Mismatch Error 13

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
TCristiano
Asked:
TCristiano
  • 2
1 Solution
 
akbCommented:
Attachment??
0
 
TCristianoAuthor Commented:
0
 
ChloesDadCommented:
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
 
TCristianoAuthor Commented:
Brilliant! Thanks for the quick response!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now