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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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
 
Upvote 0

Forum statistics

Threads
1,212,933
Messages
6,110,757
Members
448,295
Latest member
Uzair Tahir Khan

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
Back
Top