Hello everyone
I'm working on a bigger project and, as I'm the only person working on this, I need some help from time to time. As I have lots of data, I decided to work with userforms and let VBA do the calculation.
To calculate, for example, the date of the first order, I use the following array formula in Excel:
- where A3 would be the cell with the customer's ID number. CustomerID and OrderDate are named ranges.
With VBA, I wrote following function:
The procedure is called when a userform doubleclicks on a listview:
When this function is called, I get the following runtime error message: Error 1004 - The item with the specified name wasn't found.
I think that the problem is caused with the named ranges CustomerID and OrderDate.
This problem doesn't occur on all computer.
What is wrong with this code? How do you write an array formula in VBA with Evaluate?
Thank you so much for your help.
Maria
PS: Unfortunately, I cannot upload part of my spreadsheet to this forum which might help you understand my problem.
I'm working on a bigger project and, as I'm the only person working on this, I need some help from time to time. As I have lots of data, I decided to work with userforms and let VBA do the calculation.
To calculate, for example, the date of the first order, I use the following array formula in Excel:
Code:
{=MIN(IF(CustomerID=A3,OrderDate))}
With VBA, I wrote following function:
Code:
Public Function FirstPurchase(ID As Integer) As Date
FirstPurchase= Evaluate("MIN(IF(CustomerID=" & ID & ",OrderDate))")
End Function
Code:
Private Sub ListViewCustomers_DblClick()
Dim intCustomerRow as Integer
intCustomerRow = ListViewCustomers.SelectedItem.Index + 2
'MsgBox intKundenID
Call GetData(intCustomerRow )
End Sub
I think that the problem is caused with the named ranges CustomerID and OrderDate.
This problem doesn't occur on all computer.
What is wrong with this code? How do you write an array formula in VBA with Evaluate?
Thank you so much for your help.
Maria
PS: Unfortunately, I cannot upload part of my spreadsheet to this forum which might help you understand my problem.
Last edited: