For some reason, it seems that this following line returns the value its supposed to be searching for instead of the range where it finds the value.
Any ideas on why this might be the case?Please Login or Register to view this content.
Thanks
For some reason, it seems that this following line returns the value its supposed to be searching for instead of the range where it finds the value.
Any ideas on why this might be the case?Please Login or Register to view this content.
Thanks
Last edited by Kaigi; 06-24-2009 at 04:49 PM.
Hello Kaigai,
You're probably referring to the tool tip in VBA that shows the result of the find when you place the mouse on the variable. It will display the cell contents. To return the address, do this...
Also, you should get into the habit of declaring your variables. This can save you major headaches in coding.Please Login or Register to view this content.
However, if the search fails then dir_ee will be set to the special variable Nothing.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Star below the post.3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Thanks for the tip about Find... didn't know it would display the cell content instead of the address even though its an address value.
It turns out the Find was working fine, but the problem was that I neglected to specify which worksheet to get the data from on one of the following lines of code that referenced the found result.
Actually I have a question about variables. I declare all of my variables except for the ones that I use in "Set ...". Should I be declaring those ones too? Why do we sometimes say "Set ... " and other times use <variable> = <value>
Hello Kaigi,
Set is used to assign an Object variable to either an existing object or a new object. If you know the object type your object variable will be assigned to, you should declare it as the assigned type.
For example, in your code the variable dir_ee is being assigned to a Range. You can then declare dir_ee as a Range like this...
Sometimes you don't know the type of object returned. In this case assign your object variable as Object. This is a generic form that accepts all types of objects. The drawback is you don't get the IntelliSense feature which shows the object's properties, methods, and events as you type in VBA.Please Login or Register to view this content.
Please Login or Register to view this content.
Ah ok - I'll declare those from now on too then.
Thanks for all the clarification and help.
Hello Kaigi,
If you are satisfied with the solution(s) provided, please mark your thread as Solved.
How to mark a thread Solved
Go to the first post
Click edit
Click Go Advanced
Just below the word Title you will see a dropdown with the word No prefix.
Change to Solved
Click Save
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks