+ Reply to Thread
Results 1 to 8 of 8

Compile error: expected end of statement occurs when 'Handles' keyword is used

  1. #1
    Registered User
    Join Date
    11-13-2009
    Location
    Cumbria
    MS-Off Ver
    Excel 2016
    Posts
    87

    Compile error: expected end of statement occurs when 'Handles' keyword is used

    I'm sorry for asking what is probably a noob question, but I've just started learning VBA and don't understand why this happens. I'm trying to make a command button in a user form that initiates a sub routine when it is pressed, but when I start trying to code this subroutine using:

    Please Login or Register  to view this content.
    I get the error message; 'Compile error: expected end of statement occurs' with the word 'Handles' highlighted.

    Any help is much appreciated,

    Rowan
    Last edited by RowanB; 12-28-2011 at 04:26 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Compile error: expected end of statement occurs when 'Handles' keyword is used

    The signature for a VBA command button click event is just

    Please Login or Register  to view this content.
    Last edited by shg; 12-28-2011 at 03:38 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Compile error: expected end of statement occurs when 'Handles' keyword is used

    The code you have is VB.Net and not VBA.
    Remember what the dormouse said
    Feed your head

  4. #4
    Registered User
    Join Date
    11-13-2009
    Location
    Cumbria
    MS-Off Ver
    Excel 2016
    Posts
    87

    Re: Compile error: expected end of statement occurs when 'Handles' keyword is used

    Thanks a lot. I guess I've bought a big fat book that doesn't have much use to me. I bought 'Mastering Visual Basic 2010'. At least I can focus on studying something else while I wait for a new book to arrive I guess. Are there are any books you can recommend to me please?

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Compile error: expected end of statement occurs when 'Handles' keyword is used

    Any of the VBA books by John Walkenbach or Bill Jelen are good; the VBA developers handbook is the best pure VBA book I've ever seen, but you may want more excel related ones

  6. #6
    Registered User
    Join Date
    11-13-2009
    Location
    Cumbria
    MS-Off Ver
    Excel 2016
    Posts
    87

    Re: Compile error: expected end of statement occurs when 'Handles' keyword is used

    Thanks a lot.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Compile error: expected end of statement occurs when 'Handles' keyword is used

    No problem. If you were further South, I might offer you a swap.

    Please don't forget to mark the thread solved.

  8. #8
    Registered User
    Join Date
    11-13-2009
    Location
    Cumbria
    MS-Off Ver
    Excel 2016
    Posts
    87

    Re: Compile error: expected end of statement occurs when 'Handles' keyword is used

    Ah, pity we can't trade. I bought Excel 2007 Power Programming with VBA: Mr. Spreadsheet's Bookshelf Series, Book 2. Hope it's useful. Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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