Procedure Declaration Error When Summing Form Textboxes

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
714
Office Version
  1. 365
Platform
  1. Windows
I'm trying to sum the value in 7 text boxes where the value of their coinciding combo box = "Interact". When I test this code, I get the following error:

"Compile Error: Procedure declaration does not match description of event or procedure having the same name."

The responses that I'm seeing after googling the issue, don't make any sense to me. They all seem to be related to the tile of the Private Sub, but this is how I've summed text box values in the past. Albeit, the actual calculation in other summing events didn't have an IF statement involved.

What do I need to do differently here?

Code:
Private Sub CalcInteractRefund()
If Me.cobo_FeeType1.Value = "Interact" Then
    Me.txt_InteractRefund.Value = Val(Me.txt_FeeAmt1.Text)
ElseIf Me.cobo_FeeType2.Value = "Interact" Then
    Me.txt_InteractRefund.Value = Val(Me.txt_InteractRefund.Text) + Val(Me.txt_FeeAmt2.Text)
ElseIf Me.cobo_FeeType3.Value = "Interact" Then
    Me.txt_InteractRefund.Value = Val(Me.txt_InteractRefund.Text) + Val(Me.txt_FeeAmt3.Text)
ElseIf Me.cobo_FeeType4.Value = "Interact" Then
    Me.txt_InteractRefund.Value = Val(Me.txt_InteractRefund.Text) + Val(Me.txt_FeeAmt4.Text)
ElseIf Me.cobo_FeeType5.Value = "Interact" Then
    Me.txt_InteractRefund.Value = Val(Me.txt_InteractRefund.Text) + Val(Me.txt_FeeAmt5.Text)
ElseIf Me.cobo_FeeType6.Value = "Interact" Then
    Me.txt_InteractRefund.Value = Val(Me.txt_InteractRefund.Text) + Val(Me.txt_FeeAmt6.Text)
ElseIf Me.cobo_FeeType7.Value = "Interact" Then
    Me.txt_InteractRefund.Value = Val(Me.txt_InteractRefund.Text) + Val(Me.txt_FeeAmt7.Text)
End If
End Sub
Private Sub txt_FeeAmt1_Exit()
Call CalcInteractRefund
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
The declaration should look like this:

Code:
Private Sub txt_FeeAmt1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
 
Upvote 0
that error usu means you have 2 routines with the same name.
you are only allowed 1 sub called: CalcInteractRefund

do a ctl-F to find:
Sub CalcInteractRefund
or
Sub txt_FeeAmt1_Exit

(or you erased some parameters)
since nothing else is declared.
 
Last edited:
Upvote 0
Thanks @RoryA! I went back and looked at another app I have that sums, and noticed that I forgot to add that verbiage to this one.
 
Upvote 0
If you use the dropdowns at the top of the code window, the IDE will create the declarations for you.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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