This is a snippet of code in a larger macro, but this one is giving me a 1004 error and I don't know why:
Public testSheet As String
Public nm As Name
Sub DeleteNamedRangeInWorksheet()
For Each nm In ThisWorkbook.Names
If nm.RefersToRange.Worksheet.Name = testSheet Then
nm.Delete
End If
Next nm
End Sub
My goal is resize the Named Range after adding rows to the range. I have a define Named Range routine that works, so I thought I would delete the named range and then readd it. I did try some resizing code and that gave me even more difficulty, since I have multiple worksheets in the current workbook. I am looking for a reusable sub.
Public testSheet As String
Public nm As Name
Sub DeleteNamedRangeInWorksheet()
For Each nm In ThisWorkbook.Names
If nm.RefersToRange.Worksheet.Name = testSheet Then
nm.Delete
End If
Next nm
End Sub
My goal is resize the Named Range after adding rows to the range. I have a define Named Range routine that works, so I thought I would delete the named range and then readd it. I did try some resizing code and that gave me even more difficulty, since I have multiple worksheets in the current workbook. I am looking for a reusable sub.