简体   繁体   中英

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:

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. 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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