+ Reply to Thread
Results 1 to 8 of 8

Compile Error - Detected

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Compile Error - Detected

    Hello
    What if there is 2 or more than of " Private Sub Worksheet_SelectionChange(ByVal Target As Range)".
    I received a compile error.

    here is the sample code:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,372

    Re: Compile Error - Detected

    You need to combine them into one event handler. Should be straightforward the way they are written.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,703

    Re: Compile Error - Detected

    You may not have two Subs with the same name. If you need multiple actions for the same event, you have to use logic to put them into a single sub.

    This has been compiled but not tested. If it does not do what you want please attach your file.

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Compile Error - Detected

    Ok...I think this work.
    How do I add message box between this code:
    Please Login or Register  to view this content.
    thanks.

  5. #5
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Compile Error - Detected

    I was able to figured it out.
    Thank you all.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,372

    Re: Compile Error - Detected

    You're welcome.


    Worked out what? I described what was necessary and 6SJ did it all for you.

  7. #7
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Compile Error - Detected

    Hi
    I am not good combining them into one event handler. Is there a way to rename this code?

    Private Sub Worksheet_SelectionChange(ByVal Target As Range

    Like: Private Sub Worksheet1_SelectionChange....

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Compile Error - Detected

    Not if you want it to run automatically.
    Rory

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Compile Error: Ambiguous name detected
    By trubio77 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-19-2017, 02:26 PM
  2. [SOLVED] Compile error: Ambigous name detected: Worksheet_Change
    By bjnockle in forum Excel Programming / VBA / Macros
    Replies: 42
    Last Post: 07-31-2014, 07:57 PM
  3. [SOLVED] Compile error: Ambiguous name detected: textbox4_change Solved by : Sixthsense + Norie
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-26-2014, 04:55 AM
  4. Compile Error : Ambiguous name detected
    By vasanthrs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2013, 09:58 AM
  5. VBA Compile Error: Ambiguous name detected
    By kieranoduill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2013, 05:31 PM
  6. [SOLVED] compile error ambiguous name detected!?
    By Margate in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2013, 08:49 PM
  7. Compile error: Ambiguous name detected
    By Aletha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2008, 05:48 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1