Consulting

Results 1 to 3 of 3

Thread: problem with VBA code( Ambiguous name detected)

  1. #1

    problem with VBA code( Ambiguous name detected)

    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
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    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.

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •