PDA

View Full Version : problem with VBA code( Ambiguous name detected)



veronica2016
10-15-2015, 05:25 AM
HI EVERYBODY
I am delighted to join you in this forum. I have a problem with the vba code , when I click a message tells me "Ambiguous name detected"
please can you help me?
thank you in advance

snb
10-15-2015, 06:15 AM
You can't have two same eventprocedure in 1 codemodulte:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$C$2:$E$2" Then
TextBox1 = ""
[a5].AutoFilter

End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

remove 1 of these procedures.

SamT
10-15-2015, 07:20 AM
I recommend that you only use Event Procedures to check conditions and select subs


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Condition1 Then SubA
If Condition2 Then SubB

End Sub


Or in your case


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$C$2:$E$2" Then ClearTextBox1
If Condition2 Then SubB
End Sub


Sub ClearTextBox1
TextBox1 = ""
[a5].AutoFilter
End Sub


SubB()
'
'
End Sub