Issue with VBA Code(create Calculator)

mari_hitz

Board Regular
Joined
Jan 25, 2011
Messages
101
Hi guys!

Hope everyone it's fine. I have a new dilema. I am trying to create a simple calculator for my team (it calculates the score we need with an exact formula). The issue is that I have created the same and I have put the code, however I cannot make it work.
I have created a text box (the big one) where the total must be and a couple of other text boxes where the person who uses the calculator must enter the value and according to the formula the Total will be reflected, and I have written the following code:

Code:
Private Sub Total_Change()
End Sub
Private Sub Writting_AfterUpdate()
Total.Value = (Writting.Value * 4 / 10) + (Vocabulary.Value * 2 / 10) + (Problem_Solved.Value * 3 / 10) + (Signature.Value * 1 / 10)
End Sub
Private Sub Vocabulary_AfterUpdate()
Total.Value = (Writting.Value * 4 / 10) + (Vocabulary.Value * 2 / 10) + (Problem_Solved.Value * 3 / 10) + (Signature.Value * 1 / 10)
End Sub
Private Sub Problem_Solved_AfterUpdate()
Total.Value = (Writting.Value * 4 / 10) + (Vocabulary.Value * 2 / 10) + (Problem_Solved.Value * 3 / 10) + (Signature.Value * 1 / 10)
End Sub
Private Sub Signature_AfterUpdate()
Total.Value = (Writting.Value * 4 / 10) + (Vocabulary.Value * 2 / 10) + (Problem_Solved.Value * 3 / 10) + (Signature.Value * 1 / 10)
End Sub
End Sub

Could you please take a look into this and tell me what is the error I am making?

Thanks!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Can you tell us what the error it is you are getting?
 
Upvote 0
Hi Norie,

Thanks for your prompt reply. The error that I am getting it is that the Total it is not being calculated after I complete the parts where a person should put the number for the total to be calculated.

I do not know if I am making myself clear. Please do let me know if you need more information. Thanks in advanced.

Here a link to the tool: http://www.easy-share.com/1914203301/Calculator.xls
 
Upvote 0
Mari

I can't seem to get that link to work, it asks me to enter a Captcha but nothing happens after that.

When I click the slow download button it tells me there is already a download in progress.

Anyway, when I look at the code the only problem I can see is that there is one too many End Sub.

That should actually cause a compile error and the code wouldn't run at all.

What is it that's actually happens?

You say the total isn't being calculated, is the code even being run?

One check you could make for that would be to add a breakpoint (F9) to each sub.

Then fill out the textboxes and see what happens.
 
Upvote 0
Hi Norie, Thanks for your time. Yes, I do not know why but the link is wrong.
I have tried what you did and nothing happens. I do not understand what you are saying about the code being run. I tought that after I leave the desing mode off and I complete the fields the code should be running itself. Is this wrong? I am pretty new with Visual Basic :$
 
Upvote 0
Where are the textboxes and code located?

Did you try adding a breakpoint (F9)? That's one way you'll find out if the code is being executed.
 
Upvote 0
Hi Norie, thanks for your prompt reply.

The Text boxes are located in the Excel sheet and I have pasted the code on each one of them by making double click and the VB editor appeared.
I do not know if this is relevant but when I do double click it appears:
Private SubTotal_Change() and when I try to change the "Change" to "BeforeUpdate" it does not let me and this get change but a new Private SubTotal_Change().
Maybe I had explained myself wrong but that is what happens.

Thanks Norie for all your help!
 
Upvote 0
There is no AfterUpdate (or BeforeUpdate) event for textboxes on a worksheet.

When you double click the textbox and goto the VBE you probably noticed 2 dropdowns above the code sheet.

The one on the left lists the controls, and the when you select a control the dropdown on the right lists all the events associated with it.

Have you tried just using the 'default' event Change.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top