Hi, I need some help with the following.
I have two workbooks where I need to do a lookup in between and obtain a value.
To be more precise there is one active mastersheet which contains all the data, and a map with separate sheets, and each sheet does a lookup on the mastersheet and obtain a specific value.
The lookup is done on multiple conditions.
The lookup value from the separate sheet is checked on the first column for the name, rest of the columns for the price, and color (only yellow marked items should be considered).
I also haved a third workbook where I have placed the whole code and the UDF.
This UDF works great within one workbook.
But in this setting with 3 workbooks I receive a #NAME? error. And this is what I need some help with.
I did a small research on this and I found there are solutions for this like:
- save the UDF in a personal.xls file, xla file or qualify the call with: =[Your Workbook.xls]MyFunct(Arg1, Arg2)
I've tried to place the UDF in a personal.xls file but that didn't work either
Is there an another way?
Thank you in advance for looking into it.
Here below an examle one of the separate sheets :
Here below an example of the master sheet:
And here below the UDF:
I have two workbooks where I need to do a lookup in between and obtain a value.
To be more precise there is one active mastersheet which contains all the data, and a map with separate sheets, and each sheet does a lookup on the mastersheet and obtain a specific value.
The lookup is done on multiple conditions.
The lookup value from the separate sheet is checked on the first column for the name, rest of the columns for the price, and color (only yellow marked items should be considered).
I also haved a third workbook where I have placed the whole code and the UDF.
This UDF works great within one workbook.
But in this setting with 3 workbooks I receive a #NAME? error. And this is what I need some help with.
I did a small research on this and I found there are solutions for this like:
- save the UDF in a personal.xls file, xla file or qualify the call with: =[Your Workbook.xls]MyFunct(Arg1, Arg2)
making a user-defined function accessible to all workbooks
I've got a couple of user-defined functions that I coded in via one workbook (wkb A), but would like these functions to be accessible to any workbook (wkb B...Z). How is this done so that when I start a new blank wkb I can use these user-defined functions there as well?
www.mrexcel.com
I've tried to place the UDF in a personal.xls file but that didn't work either
Is there an another way?
Thank you in advance for looking into it.
Here below an examle one of the separate sheets :
Cell Formulas | ||
---|---|---|
Range | Formula | |
B5:B6 | B5 | =GET_PRICE([fruits_source.xlsm]prices!$A$1:$D$7,$A$1,A5) |
Here below an example of the master sheet:
fruits_source.xlsm | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | Partner | Golden | Red Apple | Green Apple | |||
2 | FruitsRUs | € 1 | € 1 | € 1 | |||
3 | |||||||
4 | 4Fruits | n/a | € 1 | € 3 | |||
5 | |||||||
6 | OneADay | € 1 | n/a | n/a | |||
7 | |||||||
8 | |||||||
prices |
And here below the UDF:
Public Function GET_PRICE(ByVal RngPrices As Range, ByVal vPartner As String, vType As String) As Variant
Dim vRow As Long
Dim vColumn As Long
With Application.WorksheetFunction
vRow = .Match(vPartner, RngPrices.Columns(1), 0)
vColumn = .Match(vType, RngPrices.Rows(1), 0)
End With
'check color
If RngPrices.Cells(vRow, vColumn).Interior.Color = vbYellow Then
GET_PRICE = RngPrices.Cells(vRow, vColumn).Value
Else
'not yellow, return N/A
GET_PRICE = "Nope"
End If
End Function