![]() |
Copying Code
Could some one please give me an example of the code required to copy all the
code from 1 module into another module in the same workbook Thankyou in anticipation |
Copying Code
Roger,
Not sure WHY you would want to do that - but set a reference to MS VBA extensibility, and use code like Sub CopyModule() Dim NextLine As Integer Dim theCode As String With ActiveWorkbook.VBProject.VBComponents.Item("Module 1").CodeModule theCode = .Lines(1, .CountOfLines) End With ActiveWorkbook.VBProject.VBComponents.Add(vbext_ct _StdModule).Name = "NewModule1" With ActiveWorkbook.VBProject.VBComponents.Item("NewMod ule1").CodeModule .DeleteLines 1, .CountOfLines NextLine = .CountOfLines + 1 .InsertLines NextLine, theCode End With End Sub HTH, Bernie MS Excel MVP "Roger" wrote in message ... Could some one please give me an example of the code required to copy all the code from 1 module into another module in the same workbook Thankyou in anticipation |
Copying Code
Why would you just use Windows Copy/Paste to do that? Just insert a new
module, select all the text in your existing module and Edit/Copy it, put the cursor in your new module and then Edit/Paste it in. -- Rick (MVP - Excel) "Roger" wrote in message ... Could some one please give me an example of the code required to copy all the code from 1 module into another module in the same workbook Thankyou in anticipation |
All times are GMT +1. The time now is 01:58 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com