Use the below code it will sets up the workbook procedure. You don’t have to set the insertlines simultaneously. I hope this code works for you and your query gets solved forever.
Code:
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Address = "$D$1" Then caly2.Show
End Sub
Code:
//This procedure sets up the workbook procedure
With ActiveWorkbook.VBProject.VBComponents(ActiveSheet.CodeName).codemodule
'Add the empty procedure
.InsertLines 1, "Private Sub Worksheet_SelectionChange(ByVal target As Range)"
.InsertLines 2, "If Target.Address = ""$D$1"" Then caly2.Show"
.InsertLines 3, "end sub"
Bookmarks