```
Sub Test()
    Dim spinButton As Object
    Set spinButton = ActiveSheet.OLEObjects.Add(ClassType:="Forms.SpinButton.1", Link:=False, DisplayAsIcon:=False, Left:=276, Top:=58.5, Width:=12.75, Height:=25.5)
    spinButton.Object.Min = 1
    spinButton.Object.Max = 100
    spinButton.LinkedCell = "B2"
End Sub

```

My goal with the VBA code above is to create a simple Spin Button, which changes the value of cell "B2" by 1.

When I run the code as a macro, it gives me this error warning:

[![error](https://i.stack.imgur.com/zfdCK.jpg)](https://i.stack.imgur.com/zfdCK.jpg) 

which [they write about on the MS website here](https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/automation-error-error-440).

The thing is, my code works. As in, it creates a spin button at the right location, adds the correct properties and changes the value of the B2 cell when I click the spin button.

I'm using a completely new file with nothing in it. No other macros/modules and a completely empty spreadsheet. I use my VBA code in the "ThisWorkbook" if it makes any differences:

[![failure](https://i.stack.imgur.com/JADgG.jpg)](https://i.stack.imgur.com/JADgG.jpg)