Function works until I make it an ADD IN

Certified

Board Regular
Joined
Jan 24, 2012
Messages
189
I created two functions (located below) located in one workbook. The two codes convert foreign currency to USD. Both codes contain an array populated by data from a two separate worksheets.

I wanted to access the function in all of my workbooks so I saved the workbook as an ADD-IN, and installed the ADD-IN.

My issue is when I try to run the function in another workbook, the function shows, but it does not work. I keep on getting a #value! error.

Does anyone have an idea what the issue could be?

Code:
Function FX4q14(FCC As String, Amount As Double) As Double




Dim Myarray() As Variant
Dim i As Integer


'Myarray = Range("b2", Range("b1").End(xlDown).End(xlToRight))


Sheets("4q14").Activate
Myarray = Range("b2:e147")


For i = 1 To UBound(Myarray, 1)
    If FCC = Myarray(i, 1) Then
        FX4q14 = (Amount) * CDbl(Myarray(i, 4))
    End If
    
Next i


End Function



Code:
Function FX1q15(FCC As String, Amount As Double) As Double




Dim Myarray() As Variant
Dim i As Integer


'Myarray = Range("b2", Range("b1").End(xlDown).End(xlToRight))


Sheets("1q15").Activate


Myarray = Range("b2:e149")


For i = 1 To UBound(Myarray, 1)
    If FCC = Myarray(i, 1) Then
        FX1q15 = (Amount) * CDbl(Myarray(i, 4))
    End If
    
Next i


End Function
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You can't activate a sheet in an add-in since they're all hidden, but you don't need to - replace this:
Code:
Sheets("4q14").Activate
Myarray = Range("b2:e147")
With this:
Code:
Myarray = ThisWorkbook.Sheets("4q14").Range("b2:e147").Value
 
Upvote 0

Forum statistics

Threads
1,203,625
Messages
6,056,393
Members
444,862
Latest member
more_resource23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top