Sub ss()
Dim sh As Worksheet
Set sh = ActiveSheet
Dim wb As Workbook
Set wb = Workbooks("Book1")
For i = 1 To sh.OLEObjects.Count
Set sh = ActiveSheet
wb.VBProject.VBComponents(sh.Name).CodeModule.AddFromString ("'Private Sub DTPicker" & i & "_Change()")
wb.VBProject.VBComponents(sh.Name).CodeModule.AddFromString ("Range(""A" & i & """)" & ".Value = Me.DTPicker" & i & ".Value")
wb.VBProject.VBComponents(sh.Name).CodeModule.AddFromString ("End Sub")
Next
n = 0
For t = 1 To ThisWorkbook.VBProject.VBComponents(sh.Name).CodeModule.CountOfLines Step 3
n = n + 1
wb.VBProject.VBComponents(sh.Name).CodeModule.ReplaceLine t, "Private Sub DTPicker" & n & "_Change()"
Next
End Sub
No comments:
Post a Comment