impius
10-21-2008, 08:07 AM
Hello all,
I have the code below, it works as a command button, but when I create it as an add-in, it does not do its job. It does not error, just doesnt delete the named ranges. Do you have to write code differently in an add-in?
Thanks in advance!
If Deleterange = True Then
MsgBox "Deleterange"
Dim oneName As Name, promptStr As String
For Each oneName In ThisWorkbook.Names
With oneName
If IsError(Evaluate(.RefersTo)) Then
promptStr = .Name & " evaluates to error" & vbCrLf & "Refers To: " & .RefersTo & vbCrLf & "Delete Name?"
If MsgBox(promptStr, vbYesNo) = vbYes Then
oneName.Delete
End If
End If
End With
Next oneName
End If
I have the code below, it works as a command button, but when I create it as an add-in, it does not do its job. It does not error, just doesnt delete the named ranges. Do you have to write code differently in an add-in?
Thanks in advance!
If Deleterange = True Then
MsgBox "Deleterange"
Dim oneName As Name, promptStr As String
For Each oneName In ThisWorkbook.Names
With oneName
If IsError(Evaluate(.RefersTo)) Then
promptStr = .Name & " evaluates to error" & vbCrLf & "Refers To: " & .RefersTo & vbCrLf & "Delete Name?"
If MsgBox(promptStr, vbYesNo) = vbYes Then
oneName.Delete
End If
End If
End With
Next oneName
End If