Hi,
I know this is for Access but I was hoping someone may know about Excel and can help me.
I have created a Function in VBA for looking up a value in a grid it works fine but only if I place the Range as a string and I really need to be able to just select the cells as you would with a standard function.
Here is my Function
Vlookup is the Value to find at the Left, Hlookup is the value to find at the top and GArray is the Range to look at.
Like I say it will work with Glookup(2003,20 03,"A1:G10") but I need it to work with Glookup(2003,20 03,A1:G10)
Thanks
I know this is for Access but I was hoping someone may know about Excel and can help me.
I have created a Function in VBA for looking up a value in a grid it works fine but only if I place the Range as a string and I really need to be able to just select the cells as you would with a standard function.
Here is my Function
Code:
Function GLookup(VLookup, HLookup, GArray) Dim TArray As String Dim BArray As String Dim VArray As String Dim HArray As String Dim VRef As Integer Dim HRef As Integer Dim Grid As Range TArray = Left(GArray, InStr(GArray, ":") - 1) BArray = Right(GArray, Len(GArray) - (Len(TArray) + 1)) VArray = TArray & ":" & IIf(IsNumeric(Mid(TArray, 2, 1)), Left(TArray, 1), Left(TArray, 2)) VArray = VArray & IIf(IsNumeric(Mid(BArray, 2, 1)), Right(BArray, Len(BArray) - 1), Right(BArray, Len(BArray) - 2)) HArray = TArray & ":" & IIf(IsNumeric(Mid(BArray, 2, 1)), Left(BArray, 1), Left(BArray, 2)) HArray = HArray & IIf(IsNumeric(Mid(TArray, 2, 1)), Right(TArray, Len(TArray) - 1), Right(TArray, Len(TArray) - 2)) VRef = WorksheetFunction.Match(VLookup, Range(VArray), 0) HRef = WorksheetFunction.Match(HLookup, Range(HArray), 0) GLookup = WorksheetFunction.Index(Range(GArray), VRef, HRef) End Function
Like I say it will work with Glookup(2003,20 03,"A1:G10") but I need it to work with Glookup(2003,20 03,A1:G10)
Thanks
Comment