1

I'm trying to write a code to using VB.Net to delete the Named Range of the activecell. I can't seem to figure out the correct syntax for this. Can someone please help?

        Dim xlApp As Excel.Application

        xlApp = GetObject(, "Excel.Application")

        xlApp.ActiveCell.Name.Name.Delete()

Thanks in advance.

1 Answer 1

2

The Application.ActiveCell property returns a Range object.

The Range.Name property returns a Name object.

The Name.Name property returns a string.

So, the statement:

xlApp.ActiveCell.Name.Name.Delete()

is trying to call the nonexistent Delete method on a string.

The statement should be:

xlApp.ActiveCell.Name.Delete()

to call the Name.Delete method.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @TnTinMan for helping me with this. Much appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.