ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What is the quickest way to copy codes in Sheets? (https://www.excelbanter.com/excel-programming/301733-re-what-quickest-way-copy-codes-sheets.html)

Bob Phillips[_6_]

What is the quickest way to copy codes in Sheets?
 
Anson ,

This is because sheet modules are class modules, but when you export them,
the link into the actual sheet is lost. Importing them doesn't work as the
sheet modules already exist, and so the import creates new class modules.

You need a different approach here, either write the code directly, or put
it in a text file and add the code form the text file.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Anson" wrote in message
...
I have wrote some codes to copy the modules and forms from the one

workbook to another. Most of them worked fine, but the sheets modules were
turned into class modules. I know I could manually enter the exact lines
from the sheets and have the macro to wirte it, but is there a way to copy?

This is the section that deals with coping modules:

'---------------------------------------------------------------------------
------
Dim NewBook As Workbook
Dim VBComponent As VBIDE.VBComponent, ModName As String

'Copy Modules
ModName = ThisWorkbook.Path & "\Merit Worksheet Code.txt"
For Each VBComponent In ThisWorkbook.VBProject.VBComponents

VBComponent.Export ModName
NewBook.VBProject.VBComponents.Import ModName
Kill ModName

Next VBComponent





All times are GMT +1. The time now is 02:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com