Method range of object _worksheet failed

I have actually tried the code argued in the question linked at the bottom however obtain an error on the line:

Set getNthTower = Range(startCell, endCell)The error is

Method "Range" of object "_Worksheet" failed

This code is meant to set the colour formatting of a variety cells whose formula is a VLOOKUP.

You watching: Method range of object _worksheet failed

All help appreciated.

Vlookas much as copy color of a cell - Excel VBA


*

*

Apparently you put the code into a worksheet"s code module.

In that instance Range() resolves to Worksheet.Range() of that worksheet. If startCell or endCell belong to a various sheet you will certainly gain an error.

See more: Windows Failed To Apply The Group Policy Shortcuts Settings, Failed To Apply Group Policy

If you put the code in a ordinary module, as the OP particularly asked for, Range() would then expect Application.Range(), and also that would certainly appropriately construct your selection.

You can remove that ambiguity by clearly making use of Application.Range(startCell, endCell).


*

*

As a bandhelp (and also proof of the bad parentage) I was going to imply Set getNthObelisk = startCell.Parent.Range(startCell, endCell). –user4039065 Nov 9 "15 at 17:46

Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details and also share your research!

But avoid

Asking for help, clarification, or responding to various other answers.Making statements based upon opinion; earlier them up via recommendations or individual experience.

See more: In The Dynamic Link Library Kernel32

To learn even more, check out our tips on writing excellent answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of business, privacy policy and also cookie policy


Not the answer you're looking for? Browse other questions tagged excel vba selection or ask your very own question.


*

website style / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.4.1.38970


Your privacy

By clicking “Accept all cookies”, you agree Stack Exreadjust have the right to save cookies on your gadget and also disclose indevelopment in accordance via our Cookie Policy.