Error using macro to copy-paste checkboxes.

Kari001

New Member
Joined
Jul 16, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I'm running into an error when trying to use a macro to copy a checkbox from one cell and paste it in another cell. "Run-time error '1004': The item with the specified name wasn't found".

Can someone help me please?

VBA Code:
Sub Macro13()
'
' Macro13 Macro
'

'
    ActiveSheet.Shapes.Range(Array("Check Box 19")).Select
    Selection.Copy
    Range("H60").Select
    ActiveSheet.CheckBoxes.Add(573.75, 1569, 19.5, 22.5).Select
    ActiveSheet.Paste
    ActiveSheet.Shapes.Range(Array("Check Box 163")).Select
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
This code looks odd for a few reasons. But one question pops out which is, why, if you are copying a checkbox, are you adding another checkbox and then pasting the check box you copied.

Can you re-explain your situation, for example, can you say, without the code, the essence of what you are doing. For example, are you trying to copy a particular checkbox which might be located in a reliable place (maybe it won't be but that is part of the explanation needed), and are you pasting it somewhere else, if so, where else.

Probably the specified name was not found because the names of the checkboxes you reference (19 and 163) are really named something else. Please specify what kind of checkboxes they are -- created from the Form menu or are they activex checkboxes. This is an important point because in a new fresh workbook for example, when you add a check box from the Form menu, its name will be Check Box 1 whereas from the ActiveX menu the name will be CheckBox1 without any spaces in the name.
 
Upvote 0
The whole error was with that line, thank you so much for pointing it out. Everything works as it should, problem solved.
When using the 'Record Macro' to record a simple copy-paste of a checkbox this line will be generated and it will not work, removing it solves the issue.
Again, thank you very much.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top