PC Review


Reply
Thread Tools Rate Thread

Custom Vlookup Function

 
 
cla99009
Guest
Posts: n/a
 
      19th Aug 2008
I have pretty extensive sub programming experience, but I've had only modest
success writing custom functions as they take slightly different parameters.

I have a workbook with several tabs, one for each month (Jan 08, Feb 08,
etc), and an output tab. Each tab contains a report of the total payroll for
each of up to a few hundred employees for that month. I need the output tab
to be a pivot table of sorts, with each employee's name and number in rows
down columns A and B. I want columns C, D, E, and so on, to output the net
payroll for each employee for each month. I have a complex string of a
vlookup that does that already in place, but I have to change the vlookup to
the appropriate month as well as build into it several if(isna()) functions
to return a 0 if a given employee has no payroll in a given month. I would
like to build a custom function that will look something like this:

Function LookupPay(EmployeeNumber as string, MonthTab as string)

I'm having trouble finding the correct syntax that will take the MonthTab as
an imput and use that to designate the correct sheet.

Any help would be greatly appreciated.
 
Reply With Quote
 
 
 
 
Erin Searfoss
Guest
Posts: n/a
 
      19th Aug 2008
If I understand correctly, in this instance you don't need to write a custom
function. Instead you can use the INDIRECT function of Excel.

EmpID Jan 08 Feb 08 Mar 08
555 654 5683 564
444 78 6546 78
333 54 8686 55
222 654 3546 5348


where cell B2 contains this formula:

=VLOOKUP($A2,INDIRECT("'"&B$1&"'!PayChart"),5,0)

In this example the column headers are entered as text so that they match
exactly the sheet names. Each month sheet contains a range named PayChart of
which the employee ID's are in the first column and the net pay in the 5th
column. The use of INDIRECT in this case gives the same result as
=VLOOKUP($A2,'Jan 08'!PayChart,5,0)

Hope this helps.

Erin


"cla99009" wrote:

> I have pretty extensive sub programming experience, but I've had only modest
> success writing custom functions as they take slightly different parameters.
>
> I have a workbook with several tabs, one for each month (Jan 08, Feb 08,
> etc), and an output tab. Each tab contains a report of the total payroll for
> each of up to a few hundred employees for that month. I need the output tab
> to be a pivot table of sorts, with each employee's name and number in rows
> down columns A and B. I want columns C, D, E, and so on, to output the net
> payroll for each employee for each month. I have a complex string of a
> vlookup that does that already in place, but I have to change the vlookup to
> the appropriate month as well as build into it several if(isna()) functions
> to return a 0 if a given employee has no payroll in a given month. I would
> like to build a custom function that will look something like this:
>
> Function LookupPay(EmployeeNumber as string, MonthTab as string)
>
> I'm having trouble finding the correct syntax that will take the MonthTab as
> an imput and use that to designate the correct sheet.
>
> Any help would be greatly appreciated.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
using vlookup in a custom function slug Microsoft Excel Programming 3 15th Mar 2007 04:08 PM
Possible -- a custom format on text, similar to a VLOOKUP() function? Randy Harmelink Microsoft Excel Programming 1 3rd Nov 2006 12:32 AM
Custom function to simplify vlookup formula John James Microsoft Excel Programming 3 15th Mar 2006 09:39 PM
Custom Function VLookup =?Utf-8?B?TWFydGlu?= Microsoft Excel Misc 1 15th Mar 2006 08:32 PM
vlookup, IF or Match? or is a custom function required? =?Utf-8?B?Um9iIEJvdXJyaWFndWU=?= Microsoft Excel Worksheet Functions 1 18th Mar 2004 11:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 AM.