I'm a new member although I visit this website a lot. I can't add a new item to my listobject if I choose random cells. For example:
ActiveWorkbook.Names.Add _
Name:="ErrorExample", _
RefersTo:="=Sheet1!$A$1;Sheet1!$A$2;Sheet1!$A$3"
But if I choose cells in the same range I don't get the runtime error 1004... For example:
ActiveWorkbook.Names.Add _
Name:="RightExample", _
RefersTo:="=Sheet1!$A$1:$A$3"
You are adding a Defined Name to the workbook. It has nothing to do with a ListObject
.
The reason you are getting the error it that you are concatenating your range addresses with semicolons instead of commas.
ActiveWorkbook.Names.Add Name:="ThisWorks", RefersTo:="=Sheet1!$A$1,Sheet1!$A$2,Sheet1!$A$3"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.