Thread: Error 2015
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Error 2015

Jeff,
how about staying with one thread and not have 4 or 5 going in different
workgroups on the same problem.

How do you get a sheet name of MAY in a CSV file?

I suggested one solution. If your formula works in a worksheet, it should
work as suggested:

sName = "'[Option 11 CSV.xls]May'"
sform = "=IF(ISNA(MATCH(1,(XXX!A1:A10000=20)*(XXX!B1:B1000 0=6)*" & _
"(XXX!C1:C10000=""F"")*(XXX!E1:E10000=""Escada""), 0)),0,INDEX(" & _
"XXX!F1:F10000,MATCH(1,(XXX!A1:A10000=20)*(XXX!B1: B10000=6)*" & _
"(XXX!C1:C10000=""F"")*(XXX!E1:E10000=""Escada""), 0)))"
s1 = Replace(sForm,"XXX",sname)

Now s1 contains the formula as a string that can be evaluated or assigned to
the formula property of a cell.

res = Evaluate(s1)

or
ActiveCell.Formula = S1

however, your Formla is too long to use FormulaArray - it only accepts about
255 characters.

if there will only be a match on one row, then you might want to use
sumproduct in the formula placed in the cell so you don't have to use
FormulaArray.

--
Regards,
Tom Ogilvy




"Jeff" wrote:

Hello,
I need help,
This is my VBA macro
Sub Macro5()
Dim mtchValue As Variant
Dim getvalue As Variant
Dim sh As String
Dim fname
fname = Application.GetOpenFilename
Workbooks.Open filename:=fname
sh = "'[" & fname & "]May'!"
mtchValue = Application.Evaluate("MATCH(1,(" & sh & "A1:A10000=20)*" &
"(" & sh & "B1:B10000=6)*" & "(" & sh & "C1:C10000=""F"")*" & "(" & sh &
"E1:E10000=""Escada""),0))")
If Not IsError(mtchValue) Then
getvalue = Application.Evaluate("Index(" & sh & "F1:F10000," &
mtchValue & ")")
End If
Can anyone tell me why I have "Error 2015" on mtchvalue?


End Sub
--
Regards,
Jeff