bdautrich
New Member
- Joined
- Sep 22, 2022
- Messages
- 19
- Office Version
- 2013
- Platform
- Windows
Working on an application to track inventory and orders, The application has several worksheets that are like databases with inventory or order info. We have gone live with the software but the users have found some issues and there are a few additional features we want to deploy. We have a new version of the software that fixes the bugs and adds the new features and I am working on a user form that the user can click on a button to copy these "datatbases" (Worksheets) to the new version of the application. I am able to copy the worksheets but when I copy the worksheets I also copy any defined names on them. To avoid duplicates I am trying to delete the the defined names in the new version of the application. I need them there to test the software to make sure it works. Here is the code to delete the defined names.
ActiveWorkbook.Names("Strains!Strains").Delete
When I run this I get Run time error number 1004 "an Application-defined or object-defined error .
To check the defined names I wrote this code to check on them
Set Sht = ThisWorkbook.Sheets("Debug") 'Make you change the sheet reference if needed
On Error Resume Next
For Each nm In Names
With Sht.Range("A" & Rows.Count).End(xlUp)(2)
.Value = nm.Name
Dname = nm.Name
MsgBox ("Defined Name is " & Dname)
.Offset(, 1) = "'" & nm.RefersTo
Dref = nm.RefersTo
MsgBox ("Defined name refers to " & Dref)
.Offset(, 2).Formula = "=Len(" & Sht.Range("A" & Rows.Count).End(xlUp).Address & ")"
End With
Next nm
And the output in spreadsheet and on screen tracks what I expect
Here is the output for the Strains database which is on a worksheet called Strains
Would like to fix this if possible. Only other option is to delete the defined names from the new version and tell user they must copy databases first before doing anything when we deploy the new version
Any help would be greatly apprecited
ActiveWorkbook.Names("Strains!Strains").Delete
When I run this I get Run time error number 1004 "an Application-defined or object-defined error .
To check the defined names I wrote this code to check on them
Set Sht = ThisWorkbook.Sheets("Debug") 'Make you change the sheet reference if needed
On Error Resume Next
For Each nm In Names
With Sht.Range("A" & Rows.Count).End(xlUp)(2)
.Value = nm.Name
Dname = nm.Name
MsgBox ("Defined Name is " & Dname)
.Offset(, 1) = "'" & nm.RefersTo
Dref = nm.RefersTo
MsgBox ("Defined name refers to " & Dref)
.Offset(, 2).Formula = "=Len(" & Sht.Range("A" & Rows.Count).End(xlUp).Address & ")"
End With
Next nm
And the output in spreadsheet and on screen tracks what I expect
Here is the output for the Strains database which is on a worksheet called Strains
Would like to fix this if possible. Only other option is to delete the defined names from the new version and tell user they must copy databases first before doing anything when we deploy the new version
Any help would be greatly apprecited
Strains | =Strains!$A$1:$A$153 | 7 |