I have messed with this off and on all day. If someone can set me straight I would appreciate it. I am trying write a function that uses the Vlookup worksheetfuntion in VBA.
Function TestGivingAmount(AssetID As Integer)
Dim AnnualGiving As Long
Dim GivingDetail2 As Range
Set GivingDetail2 = Worksheets("Giving").Range("I17:Z19")
AnnualGiving = Application.WorksheetFunction.VLookup(AssetID, GivingDetail2, 3, False)
end function
It returns a value of 0, but it shouldn't.
Is there something obviously wrong here?
I want it to look up assetID 12, entered from a cell, in range I17:Z19, and return the value in the 3rd colum.
I have tried everything I can think of, even hard coding the values in the code.
Woody Hays
Function TestGivingAmount(AssetID As Integer)
Dim AnnualGiving As Long
Dim GivingDetail2 As Range
Set GivingDetail2 = Worksheets("Giving").Range("I17:Z19")
AnnualGiving = Application.WorksheetFunction.VLookup(AssetID, GivingDetail2, 3, False)
end function
It returns a value of 0, but it shouldn't.
Is there something obviously wrong here?
I want it to look up assetID 12, entered from a cell, in range I17:Z19, and return the value in the 3rd colum.
I have tried everything I can think of, even hard coding the values in the code.
Woody Hays