Ambiguous name detected: FinalStatus

ChetShannon

Board Regular
Joined
Jul 27, 2007
Messages
133
Office Version
  1. 365
Platform
  1. Windows
This should be an easy one I'm guessing. I have a module and a user form in which I have some public variables declared in order to pass values to and from the user form back to the single main code module. I then copied the entire module and form and created a new module and new user form to add some new features to the code without wrecking the previous (working well) code. So I basically created a fresh copy of this working code and I'm working on adding features to the new code. (That's when the ambiguous errors started.)

The problem I'm having is the new code is coming up with errors of "Ambiguous name detected: FinalStatus". It seems like this is happening because I have the same variable names PUBLICLY declared in the original code and the new code has the same variable names and there is hence confusion. But don't I have to declare the variables as PUBLIC in order to pass the variable information back from the user form to the main code? (Maybe not?)..

What I'm showing below are my publicly defined variables that pass the values to and from the user form.

Public TextString2 As String
Public FormTextToShow2 As String
Public PrelimStatus As Boolean
Public FinalStatus As Boolean
'Public Locationx As String
Public MinMinutesToKeep As String
Public FilterOut As Boolean
Public SaveToDesktop2 As Boolean
Public SaveToMyDocs2 As Boolean
Public SaveToFltSched As Boolean
Public SaveToGeneral As Boolean
Public RunStatus As Boolean
Public SaveNo As Boolean
Sub FLT_SCHED_CHANGE_FORMATTER_V8Exp()
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
If the line
Code:
Public LocationX as String
is in a normal module, it should appear nowhere else in your project.

Public variables need to be declared only once in the project (and in a normal module, not an object module like a userform or worksheet)
 
Upvote 0
Yes I did just declare the Public variables one time throughout the whole project. That is the way I have it now.
 
Upvote 0
The only other thing that I can think of is you might have procedure or an argument named LocationX.

Have you used Find in the VBEditor to search the whole project for that string?
 
Upvote 0
I will try what you said. In the meantime I just re-named the public variables that were the same as in some other projects in my personal.xls and now i don't get the ambiguous message. I think something is wrong in my understanding of why these variables are seen as duplicates or ambiguous. Will try your newest suggestion. Thanks.
 
Upvote 0
Have you considered passing variables as arguments rather than via a Public variable.


Code:
' public variable method

Public myString As String

Sub Test()
    myString = "Hello"
    Call ShowString
End Sub

Sub ShowString
    MsgBox myString
End Sub

VS.

Code:
' pass as argument

Sub Test2()
    Call ShowAString("hello")
Exit Sub

Sub ShowAString(aString as String)
    MsgBox aString
End Sub
 
Upvote 0
Thanks - I will try that. That will make it simpler when i'm modifying a project where I'm keeping the original project there so there won't be any interference between the old project and the new project.
 
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