+ Reply to Thread
Results 1 to 7 of 7

OnClick Sub Deletion from VBE

  1. #1
    Registered User
    Join Date
    02-12-2006
    Posts
    54

    OnClick Sub Deletion from VBE

    Hello

    I have the following code in Sheet1:

    Please Login or Register  to view this content.
    and I have a button in a form, and when I click on it I want it to delete that Sub (the Some_Name()) entirely from Sheet1 VBE

    What's the code for that?

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning cgi_pro

    I can sort out some code fot that for you. Before I do can you just confirm that the code is in Sheet1's module - not a regular code module? It makes a difference...

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    02-12-2006
    Posts
    54
    Yes, it's in a sheet that I called (PlayersList) as its codename instead of the default Sheet1

    Thank you in advance

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi cgi_pro

    OK, have a look at he code below :

    Please Login or Register  to view this content.
    You're going to have to set the relevant references for this to work : if you didn't have to do it after my last post to you, have a look here for a refresher :

    http://www.excelforum.com/showthread.php?t=581170

    Also you will need to keep the "trust access to visual basic project" box ticked.

    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    02-12-2006
    Posts
    54
    Thanks a lot dominicb

    But can you please explain to me the following in the "ProcStartLine("Some_Name", vbext_pk_Proc)"
    • What are you referring this "Some_Name" to? I mean what do I put in its place?
    • What's that vbext_pk_Proc?
    • What value does this ProcStartLine return? I believe the line number of rhtta procedure right?

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi cgi_pro

    Does the code not work or are you just dissecting to find out how it works? I wrote the routine for you based on the information you gave me. Some_Name is what you have inferred is the name of your routine in the above code, which I thought suspicious at the time - if your routine is realy caled "test"
    Please Login or Register  to view this content.
    then replace it with test.

    vbext_pk_Proc is a VBA instruction from the VB Project Extensibility sub set (which is why you check the reference).

    .ProcStartLine (and ProcCountLines) are commands to determine the start and lebgth of the code - you then delete starting from the startline for the number of lines.

    HTH

    DominicB

  7. #7
    Registered User
    Join Date
    02-12-2006
    Posts
    54
    Thanks again dominicb

    you're a good help

+ 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