I'm working on a sheet where I create checkboxes.
I use the following code to create the checkbox:
Sub AddCheckbox()
Dim vert As Integer
Dim MyTop As Integer
vert = Sheets("Overview").Range("P2").Value
Sheets("Database").Activate
MyTop = 15 * (vert - 1)
ActiveSheet.CheckBoxes.Add(770, MyTop, 1, 1).Select
With Selection
.Caption = ""
.Value = xlOff
.LinkedCell = "K" & vert
.Display3DShading = False
End With
End Sub
This piece works perfectly until I call it from some other part of the script. At this point I'm getting the message "name is not defined" (roughly translated). Why?
When the script directly starts, a checkbox is created and the linked cell works fine. When the script is called, a checkbox is created with a caption and without link to the cell.