VBA Create Module from Module

Опубликовано: 05 Сентябрь 2017
на канале: VBA Tutorial
1,618
14

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


На этой странице сайта вы можете посмотреть видео онлайн VBA Create Module from Module длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь VBA Tutorial 05 Сентябрь 2017, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,618 раз и оно понравилось 14 зрителям. Приятного просмотра!