![]() |
Application prefix or not
when creating some code, via the record macro function I find that
sometimes, for it to run succesfully, I need to add "Application" immediately before some of the lines. eg. Range ("A1") would become Application.Range ("A1") for that line to be accepted. Can someone tell me why, and what the rule is here? Rob |
Range does not require a qualifier so I don't know why you're finding that
it does. From Help: "When used without an object qualifier, this property is a shortcut for ActiveSheet.Range (it returns a range from the active sheet" -- Jim "Rob" <NA wrote in message ... when creating some code, via the record macro function I find that sometimes, for it to run succesfully, I need to add "Application" immediately before some of the lines. eg. Range ("A1") would become Application.Range ("A1") for that line to be accepted. Can someone tell me why, and what the rule is here? Rob |
I'm certainly not an expert at this and I only used Application from a
suggestion I received quite a long time ago for another code I was trying to develop. I found that this code I'm working on also won't give the correct result or proceed without it. One thing which might make the difference is that the range being referred to is in another workbook (open as the code runs) from the workbook running the code. I don't understand what is meant bt object qualifier and what that has to do with this situation. I generally start my code by recording a macro and then adding/modifying as I know how (which is quite limited). The macro recorded records the process well but when I try and run it, it stops at odd lines and when I add Application to those lines it seems to work fine. It's very confusing and I just wondered why and if maybe I was doing something wrong for me to require this. I don't always have this problem when using range, but maybe it's because as I said about the code referring to another workbook as when I use range to refer to a cell within the workbook that's running the code, I don't need the term Application as a prefix. Rob "Jim Rech" wrote in message ... Range does not require a qualifier so I don't know why you're finding that it does. From Help: "When used without an object qualifier, this property is a shortcut for ActiveSheet.Range (it returns a range from the active sheet" -- Jim "Rob" <NA wrote in message ... when creating some code, via the record macro function I find that sometimes, for it to run succesfully, I need to add "Application" immediately before some of the lines. eg. Range ("A1") would become Application.Range ("A1") for that line to be accepted. Can someone tell me why, and what the rule is here? Rob |
All times are GMT +1. The time now is 02:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com