简体   繁体   English

Excel - VBA - 公式错误1004 -

[英]Excel - VBA - formula error 1004 -

I'm getting an run-time error '1004' application-defined or object-defined error when I'm using the following vba code: 当我使用以下vba代码时,我收到运行时错误“1004”应用程序定义或对象定义错误:

Private Sub CommandButton1_Click()

Dim formul as String

'Run Tercih14

formul = "=vlookup($c$15;'Şube Listesi'!$B:$J;9;FALSE)"


Sheet35.Range("F12").Formula = formul

End Sub

I can change the value of the F12 cell.assign different formulas like =sum(A1:A2) etc. If I create a new sheet and edit the code for the new sheet it works fine with the vlookup formula. 我可以更改F12 cell.assign的值。 F12 cell.assign不同的公式,如=sum(A1:A2)等。如果我创建一个新工作表并编辑新工作表的代码,它可以正常使用vlookup公式。 I checked, the sheet is not protected . 我检查过,表格没有受到保护。 I'm having trouble figuring out what the problem is here. 我无法弄清楚这里的问题是什么。 Hope you guys can help me find the solution. 希望你们能帮助我找到解决方案。

Change 更改

"=vlookup($c$15;'Şube Listesi'!$B:$J;9;FALSE)"

to

"=vlookup($c$15,'Şube Listesi'!$B:$J,9,FALSE)"

You are using ;'s instead of ,'s 你正在使用;而不是,

I had the same kind of issue with a formula containing variable 我对包含变量的公式有同样的问题

        Dim Instruc As String
        Instruc = "=MAX(R" & CStr(suiv) & ";S" & CStr(suiv) & " )"
        MAIN.Cells(suiv, 20).Formula = CStr(Instruc)

When I use the ; 我用的时候; caracter in the formula, I always get the run-time error '1004' application-defined or object-defined error I used a variant of the formula with the : caracter 公式中的caracter,我总是得到运行时错误'1004'应用程序定义或对象定义的错误我使用了公式的变体:caracter

        Dim Instruc As String
        Instruc = "=MAX(R" & CStr(suiv) & ";S" & CStr(suiv) & " )"
        MAIN.Cells(suiv, 20).Formula = CStr(Instruc)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM