+ Reply to Thread
Results 1 to 10 of 10

how can i test for module1 (and userforms) and delete them if they are found

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    how can i test for module1 (and userforms) and delete them if they are found

    i have a macro that in part, copies module1 and userforms1-3 to a target workbook. what i want to do now is test for module1 in the target workbook and delete it if found. same for userforms.

    here is my macro.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: how can i test for module1 (and userforms) and delete them if they are found

    See this page for all the information you'll need, including a function to check existence of a module

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: how can i test for module1 (and userforms) and delete them if they are found

    Some more information... If you are iterating a collection deleting objects then you should work backwards to avoid problems.

    Please Login or Register  to view this content.
    You also don't need to activate a sheet to delete it...

    Please Login or Register  to view this content.
    Last edited by cytop; 02-24-2017 at 10:34 AM.

  4. #4
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how can i test for module1 (and userforms) and delete them if they are found

    thanks cytop, but I will still need a little bit of help. i read through the whole article and still am not sure how to make this happen.

    i used the function VBComponentExists(VBCompName As String, Optional VBProj As VBIDE.VBProject = Nothing) but all it does is bring up the run macro dialog box.

    what am i doing wrong?

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: how can i test for module1 (and userforms) and delete them if they are found

    No idea. Post a sample of the workbook with the Check function included.

  6. #6
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how can i test for module1 (and userforms) and delete them if they are found

    ok, here it is.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how can i test for module1 (and userforms) and delete them if they are found

    you can click on the sheet and choose the button labeled "Import Sheets". that kicks off the "startSaveModule" macro. you might have to set up folders to match where I am putting the module/userform code.

  8. #8
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: how can i test for module1 (and userforms) and delete them if they are found

    First off - you have added a reference to the 'Microsoft Visual Basic Extensibility library as mentioned on that page?

    Other than that, as long as you pass a reference to the project in the new workbook, it works after the code from Chip Pearson was added.
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how can i test for module1 (and userforms) and delete them if they are found

    thanks cytop, that will work for me. appreciate the help.

  10. #10
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how can i test for module1 (and userforms) and delete them if they are found

    so this is what i did to fix the issue:

    Please Login or Register  to view this content.
    can this be simplified?

+ 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] Test Vlookup to see if value was found
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2016, 09:22 PM
  2. Test spreadsheet to work with a countdown and userforms
    By zamirkaya in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2016, 06:34 AM
  3. Test if search was found
    By PBM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-20-2009, 09:07 AM
  4. After adding userforms I can't test the program
    By js999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2007, 02:23 PM
  5. method/system to test add until match found
    By Ian Elliott in forum Excel General
    Replies: 1
    Last Post: 03-02-2006, 03:45 PM
  6. [SOLVED] Search for a test string and if found insert 'x' in clumn 'A'
    By TCL in forum Excel General
    Replies: 2
    Last Post: 09-21-2005, 01:05 PM
  7. [SOLVED] avg test failed or no virus found
    By Greg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2005, 10:06 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