Removing modules with a VBA

caramel_delight

New Member
Joined
Dec 24, 2020
Messages
4
Office Version
  1. 2011
Platform
  1. Windows
HI All,

i am new to VBA

I have been searching through the internet but cant find specifically what i am looking for

I want to remove specific modules with a VBA in all open workbooks ... e.g. module 1, module 2

However, i don't want to remove the modules within the workbook with all my macros to make this happen.

What i am trying to do is sent an excel spreadsheet to my clients. when they run the macro it will remove the modules from their workbook and replace them with new ones

I managed to import and export the modules but struggling to remove the original modules in my clients workbooks


I have some codes

Sub RemoveMod()

Dim wbk As Workbook

' Loop through open workbooks
For Each wbk In Workbooks
' Exclude source workbook, personal macro workbook and add-ins
If wbk.Name <> ThisWorkbook.Name And wbk.Name <> "PERSONAL.XLSB" And wbk.IsAddin = False Then



However, i am not sure what codes to use next

Any suggestions?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

caramel_delight

New Member
Joined
Dec 24, 2020
Messages
4
Office Version
  1. 2011
Platform
  1. Windows
i have found a specific code

how to i amend this so it ammends all workbooks ?



Sub DeleteThisModule()

Dim vbCom As Object

Set vbCom = Application.VBE.ActiveVBProject.VBComponents

vbCom.Remove VBComponent:= _
vbCom.Item("Module1")

End Su
 

Watch MrExcel Video

Forum statistics

Threads
1,130,207
Messages
5,640,848
Members
417,173
Latest member
Tuanphun

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top