Solved

vlookup in general

Posted on 2012-04-05
16
238 Views
Last Modified: 2012-04-12
Hi
i m new in excel  macros and functions can i write a simple macro that can  let the user choose to use vlookup and hlookup in general
choose the excel file or other file and create the vlookup
0
Comment
Question by:asaidi
  • 8
  • 7
16 Comments
 
LVL 80

Expert Comment

by:byundt
ID: 37814495
Excel 2003 and 2007 have a Lookup wizard that helps people create VLOOKUP and HLOOKUP formulas. The wizard is an optional install. To get it, install the Lookup add-in.
0
 

Author Comment

by:asaidi
ID: 37825422
Hi
i did not get a real solution for my question..
the wizard no allow me to do what i want..
if there is an example from experts shows how to create vlookup manually ..
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37831771
hi

do you have an example file which shows what you are trying to do....

in general yes you can create a macro which can calculate the a value based on either vlookup or hlookup....

i.e....
if a = 1 then ActiveCell.FormulaR1C1 = "=HLOOKUP(<cell>,<range>,<row>,FALSE)"
else ActiveCell.FormulaR1C1 = "=VLOOKUP(<cell>,<range>,<col>,FALSE)"
end

general concept of VLOOKUP/Hlookup =
 =vlookup(<value you want to lookup>,<range which contains the value you are looking up (this should always be the first column) and the value you want to return>,<column number of the value you want to return>, flase)
0
 

Author Comment

by:asaidi
ID: 37831874
hi wshark83
i have 2 sql table that i will export them as workbook then write my macros
please find attached 2 excel files
1 account and 2 is customer
will show all customer belongs to account
if i choose an account i can see the customers belongs to the account
thanks
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37832014
please attach the file and upload it...cannot see the file...
0
 

Author Comment

by:asaidi
ID: 37832077
sorry about that
account.XLS
customer.XLS
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37832337
can you please provide me with the column headings for the two files...also brief explanation as to how do you envisage the macro to work...or what you want the user to be able to do....
0
 

Author Comment

by:asaidi
ID: 37832418
Hi
thank you for your time
for account (primary key)
col1=auto_id
col2=system_owner(linkded to another table ignore this please)
col3=name
col4=contact
col5+col6=address
for customer
col1=auto_id(primary key)
col2=account_id(linked to account)==>auto_id of account
col3+col4=address
when i click on auto_id of account see all customers
auto_id(account)--->account_id(customer)
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 6

Expert Comment

by:wshark83
ID: 37836697
you have missed a column in the customer file...

if you want to use the account file as a driver then isn't it easier to do a query i.e.:

sleect *
from account a
left join customer b
on a.auto_id = b.account_id

or

select *
from customer
where account_id in (select auto_id from account where auto_id = 1 )
0
 

Author Comment

by:asaidi
ID: 37836756
hi
i have your sql in my script no problem it works  normally but the problem how i can make it work on excel vlookup..
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37836876
if you have the code why do you need the excel vlookup...?

anways if you want VBA you would need to loop the code until it doesn't find any occurances...here's an example on loop vba code - look at the last one "To Search a List for a Specific Record"

http://support.microsoft.com/kb/299036
0
 

Author Comment

by:asaidi
ID: 37836944
Hi
sorry about that the 2 excel i sent you only an example of what io want to do
in vlookup
i need to find for example a name when i type the code and the name i need to find him in another excel file..
is there any good example in excel about this issue
code:|________________|       name:dipslay
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37837057
do you mean to say something like this (see attached file in account tab...new column called "Customer"...?
test.xls
0
 

Author Comment

by:asaidi
ID: 37837107
exactly what i want
0
 
LVL 6

Accepted Solution

by:
wshark83 earned 500 total points
ID: 37837305
if you have multiple customer with the same account id then you would need to reverse it i.e. look up account for all customers for the vlookup to work...alternatively use the macro above to get the cell reference...as the vlookup will only get the first value...
0
 

Author Comment

by:asaidi
ID: 37837345
i will do it thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now