Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Vlookup to VBA

On Jan 21, 3:19 pm, Gemz wrote:
I posted the below on the excel worksheet function forum and was advised to
post he please see two queries below.

Thanks.

1)
I have the following formula:

=VLOOKUP(B5,INDIRECT("'"&INDEX(WSlist,MATCH(1,--(COUNTIF(INDIRECT("'"&WSlist&"'!E:E"),B5)0),0))&" '!E:E"),1,0)

It works fine but i was wondering if there is a way to get it to work as
part of a macro? If i leave it as a formula then this means that the same
sheet will have to be copied across into each new months file, i would like a
button to just do the job
instead - find the info required and put it in a new sheet that it will
automatically
be re-named "lookup". is this possible?

2)
i am looking to do another type of lookup -i have 3 different sources of
information and i have to do 3 different lookups between each source to find
out which staff member is on each:

whose on source 1 and not on source 2
whose on source 2 and not on source 1
who is on source 1 that is also on source 3


is there a quicker way around this i macro? or would it jus be 3 different
lookups?

thanks a lot for your help, really appreciate it.


Gemz,

Yeah, you can do it in VBA using the WorksheetFunction method. It
starts off like this:

someVariable = WorkSheetFunction.("VLookUp(...

And then you have to fill in all the parameters to complete the
statement. Embedding multiple WorksheetFunctions into a single VB
statement can be a bear, so it's better to calculate intermediate
values in separate VB statements using the results from one as the
parameters for the next.

To use the marco the way you intend really requires you to create a VB
function rather as sub i.e.

Public Function NewFunction(parameter1, parameter2, ...) as Variable
Type

Your code here...

End Function

And pass your parameters to the function and have the function return
the calculated value back to the target cell.

When you create a user defined function, it will appear in the
function list and selecting it will reveal a standard function dialog
box with an entry box for each parameter that you defined. Ranges are
accepted too like with regular functions.

If you want to know more, suggest you hunt around the net for advice
on building functions. But they are pretty easy to work with.

Good Luck,

SteveM
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
using a vlookup to enter text into rows beneath the vlookup cell Roger on Excel Excel Programming 1 November 29th 07 12:09 PM
Vlookup in vlookup - taking the result as array name SupperDuck Excel Worksheet Functions 2 June 2nd 07 11:05 AM
Which is faster: VLOOKUP-worksheet or VB-array VLOOKUP? erikhs[_20_] Excel Programming 1 August 6th 06 06:18 PM
Vlookup -=VLOOKUP(F9,LookUp1!$A$2:$B$1504,2,FALSE) MikeR-Oz New Users to Excel 1 March 22nd 06 09:01 AM
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"