VBA Ambiguous Name Detected: RunUserForm

n_mae

New Member
Joined
Oct 13, 2016
Messages
5
Hi there,

Total VBA newbie here. I'm creating an accounts ledger spreadsheet and have created 3 user forms: Add Invoice, Add Current Expense, Add Future Expense. I did 'Add Current Expense' first and have a button in my spreadsheet which opens the relevant User Form. It worked totally fine. Have since created the other two forms, again each with their own button to open their respective User Forms. When testing this afternoon, both 'Add Future Expense' and 'Add Invoice' work fine but 'Add Current Expense' is giving me the error:

Ambiguous Name Detected: RunUserForm

This is the code for both opening the User Form (module)...

Code:
Private Sub RunUserForm()

LedgerEntry.Show


End Sub
...and for my User Form (form)

Code:
Private Sub Enter_Click()


Dim lngRow As Long
Worksheets("Ledger").Activate
lngRow = Worksheets("Ledger").Range("B1048576").End(xlUp).Row + 1


Cells(lngRow, 2) = CEDate.Value
Cells(lngRow, 6) = CESupplier.Value
Cells(lngRow, 9) = CEAccount.Value
Cells(lngRow, 17) = CECredit.Value
CEDate.Value = ""
CESupplier.Value = ""
CEAccount.Value = ""
CECredit.Value = ""


End Sub


Private Sub UserForm_Click()

End Sub

FYI, I added the "Private" bit after the problem occurred after reading around online and not understanding a thing :) I have the problem both with and without "Private" added.

Thanks in advance!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
That's is a compilation error thrown by VBA because it found more than one procedure defined with same name.

Did you write more than one RunUserName procedure - maybe one for each form?
 
Last edited:
Upvote 0
That's is a compilation error thrown by VBA because it found more than one procedure defined with same name.

Did you write more than one RunUserName procedure - maybe one for each form?

Yeah I did, all 3 forms are activated in the same way. But I thought that was just how you did it?? :S How do I get around that if I need them all to run the same procedure? Also, I wonder what is different about my problematic one, when the other 2 will run quite happily? Thanks!
 
Upvote 0
You can't have more than one routine with the same name and the same scope. All you really need to do is change the name of one of the routines, assuming you actually need both.
 
Upvote 0
For reference, these are the codes for all 3 'Show Form' modules/macros:

The Problematic One:
Code:
Private Sub RunUserForm()


LedgerEntry.Show


End Sub

The 2 Working Fine:

Code:
Private Sub RunUserForm()


Invoice.Show


End Sub

Code:
Private Sub RunUserForm()


FutureExpense.Show


End Sub

:)
 
Upvote 0
You can't have more than one routine with the same name and the same scope. All you really need to do is change the name of one of the routines, assuming you actually need both.

But how do I do that? The routine is the 'Private Sub RunUserForm()' bit, correct? I'm not sure what I can change this to where it will still do what I want..?
 
Upvote 0
Which module(s) are those three routines in?
 
Upvote 0
What is the full code in the ShowLedgerEntryForm module? (it would have been easier if you'd posted the workbook rather than a picture of your VBE!)
 
Upvote 0

Forum statistics

Threads
1,223,932
Messages
6,175,468
Members
452,646
Latest member
tudou

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