+ Reply to Thread
Results 1 to 3 of 3

How to combine 2 unrelated procedures into one sheet

  1. #1
    Registered User
    Join Date
    05-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    43

    How to combine 2 unrelated procedures into one sheet

    I have applied 2 procedures to the same sheet. However, I get the following compile error "Only comments may appear after End Sub, End Function, or End Property".
    My code currently looks like this:

    Private Sub Protect_Sheet(ByVal Target As Range)
    'this code will protect each cell once data has been entered
    ActiveSheet.Unprotect ("password")
    Target.Locked = True
    ActiveSheet.Protect ("password")
    End Sub

    Option Explicit
    Private Sub Multiple_Selection(ByVal Target As Range)
    'this code will allow for muliple selection of a dropdown box in column G only
    ....blah blah
    End Sub

    How can I modify or combine the codes so that it registers both procedures please?

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: How to combine 2 unrelated procedures into one sheet

    Hi
    you need to plut the "option explicit" at the very top of your module, before the macros
    (not above Private Sub Multiple_Selection(ByVal Target As Range)
    then your macros should run ok

  3. #3
    Registered User
    Join Date
    05-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to combine 2 unrelated procedures into one sheet

    I have done that and the error is not coming up anymore. However, now my Protect_Sheet function doesn't work but if I delete the Multiple_Selection procedure, it does.

+ 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