|
-
Jan 23rd, 2009, 08:41 PM
#1
Thread Starter
New Member
need help with autocomplete in excel
I'm trying to build kind of an autocomplete macro for excel, but I'm new at this and have been just beating my head against the wall.
My idea was something like:
On selection change
If target cell is (sheet 1) a1 then
do untill onkey "enter" or selection change
onkey "any key"
vlookup(sheet 1 a1, sheet 2 a1-b100,2,false)
?
end
Trying to get it to, when cell a1 is selected it will use vlookup every time you press any letter or number key.
The "?" is cause I don't konw how to display the result. I would like it to show it the same way the normal autocomplete function does. If thats too tough just putting it in another cell will work.
My plan is to use this as an autocomplete function so my employees don't have to search through a list of 3000+ customers everytime thy're on a job.
Anyway, thats kinda what I want, just can't get the codes right. Never actualy use those ones before.
-
Jan 23rd, 2009, 10:18 PM
#2
Re: need help with autocomplete in excel
to specify a range use like
sheets("sheet1").range("a1")
the default property for a range is value, so if target value is the same as the value of A1 would be equal
use the intersect function to find is target is within a specified range, or the address property of target and range
maybe the find function would be better than vlookup for what you want to do, as vlookup returns the value of some cell in the vlookup range, whereas you can set a range object with find then select that range
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 24th, 2009, 12:55 PM
#3
Thread Starter
New Member
Re: need help with autocomplete in excel
What "find" function are you talking about? I couldn't find that in any of my books or in the help files.
-
Jan 24th, 2009, 04:13 PM
#4
Re: need help with autocomplete in excel
excel find method
menu > edit > find, also can be run by code
vb Code:
dim r as range set r = range("a:a").find("sometext") ' other parameters also can be used r.select
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|