Create a module from a module with vba in Excel 2007, 2010, and 2013.
Enable Visual Basic for Applications Extensibility 5.3 under Tools - References in the Visual Basic Editor to reference module objects.
Code:
Dim proj As VBIDE.VBProject
Dim comp As VBIDE.VBComponent
Set proj = ActiveWorkbook.VBProject
Set comp = proj.VBComponents.Add(vbext_ct_StdModule)
comp.Name = "Module3"
Set codemod = comp.CodeModule
With codemod
lineNum = .CountOfLines + 1
.InsertLines lineNum, "Public Sub Mod3()"
lineNum = lineNum + 1
.InsertLines lineNum, "Range(""A1"").Value = 1"
lineNum = lineNum + 1
.InsertLines lineNum, "erow = activesheet.cells(Rows.count,1).end(xlup).row"
lineNum = lineNum + 1
.InsertLines lineNum, "Range(""B1"").Select"
lineNum = lineNum + 1
.InsertLines lineNum, "ActiveCell.FormulaR1C1 = ""=If(RC[-1]=1,""""Yes"""",""""No"""")"""
lineNum = lineNum + 1
.InsertLines lineNum, "Application.OnTime Now + TimeValue(""00:00:01""), ""counter"""
lineNum = lineNum + 1
.InsertLines lineNum, "End Sub"
End With
End Sub
On this page of the site you can watch the video online VBA Create Module from Module with a duration of hours minute second in good quality, which was uploaded by the user VBA Tutorial 05 September 2017, share the link with friends and acquaintances, this video has already been watched 1,618 times on youtube and it was liked by 14 viewers. Enjoy your viewing!