
[英].Formula is producing runtime error 1004 - works for all other strings
[英].Formula Runtime error 1004 on some machines and not the other
我直接進入正題。 這是給我錯誤的行代碼:
ThisWorkbook.Worksheets("Dados").Cells(16, 10).FormulaLocal = "=-(I16)+" & a & "+(" & c & "*((" & PiZi & " ^ " & d & ")*(I16 ^ " & d & ")/(" & Pc & " ^ " & d & ")))"
上面的代碼適用於我的家用機器(創建的地方),不適用於我的實驗室或工作機器
ThisWorkbook.Worksheets("Dados").Cells(16, 10).Formula = "=-(I16)+" & a & "+(" & c & "*((" & PiZi & " ^ " & d & ")*(I16 ^ " & d & ")/(" & Pc & " ^ " & d & ")))"
第二個適用於我的實驗室和工作機器,但不適用於我的家用機器。 唯一的區別是Formula 和FormulaLocal。 我知道 FormulaLocal 可能會給我錯誤,因為不同的 excel 安裝可能有不同的語言......但公式不應該在任何地方工作嗎?
此外,如果我將單元格更改為 R16C9 而不是 I16,它會在我的家用機器上運行,而在其他機器上會出現錯誤。 我真的想要一個可以在這里隨處使用的代碼。 有人可以幫忙嗎? 謝謝
PS:變量都可以並且定義明確,但問題可能是它們有小數,因此逗號或點問題
Debug.Print (With FormulaLocal) 給我:
=-(I16)+0,549840740436919+(0,0513418101762096*((604,958825198337 ^ 1,04086742681856)*(I16 ^ 1,04086742681856)/(49,44 ^ 1,04086742681856)))
可能有更好的解決方案,主要是我使用的愚蠢方式,但這現在適用於我擁有的每台機器。 謝謝大家。
...
bloqueio = 5
On Error GoTo alternativa
ThisWorkbook.Worksheets("Dados").Cells(16, 10).Formula = "=-(I16)+" & a & "+(" & c & "*((" & PiZi & " ^ " & d & ")*(I16 ^ " & d & ")/(" & Pc & " ^ " & d & ")))"
If bloqueio = 0 Then
alternativa:
On Error GoTo -1
On Error GoTo Erro
ThisWorkbook.Worksheets("Dados").Cells(16, 10).FormulaLocal = "=-(I16)+" & a & "+(" & c & "*((" & PiZi & " ^ " & d & ")*(I16 ^ " & d & ")/(" & Pc & " ^ " & d & ")))"
End If
On Error GoTo -1
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.