VBA代码字符串到单元格不工作 - 运行时错误1004 [英] VBA code string to cell not working - run time error 1004

查看:174
本文介绍了VBA代码字符串到单元格不工作 - 运行时错误1004的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力做一些非常简单的事情。实际上它曾经正常运行,但是当我更改为Windows 7 + Office 2013时,它刚刚停止工作。



VBA 将无法工作:

 工作表(图表)。单元格(2,7)== &安培; 23,45& / PL!C& 2 

图表是我现有的表格,PL是另一个现有的表格。



如果我将手表加到右边的方程式,我得到以下公式,当粘贴到单元格(手动))时。

  = 23,45 / PL!C2 

错误我得到的是:

 运行时错误'1004':
应用程序定义或对象定义的错误

我已经研究了几个运行时错误1004个问题,但没有一个似乎是一样的问题或为我工作有任何想法吗 ?谢谢

解决方案

使用 Range.Formula属性与EN-US语法或 Range.FormulaLocal属性与您的区域区域设置。

 工作表(图表).Cells(2,7).FORMULA ==& 23.45& / PL!C& 2 
工作表(图表)。单元格(2,7).FORMULALOCAL ==& 23,45& / PL!C& 2

VBA以非常EN-US为中心,为所有区域设置提供翻译, fly会创造一个很大的开销。


I'm trying to accomplish something very simple. Actually it used to run normally but when I changed to windows 7 + Office 2013 it just stopped working.

The following line in VBA won't work:

Worksheets("Charts").Cells(2, 7) = "=" & "23,45" & "/PL!C" & 2

Charts is an existent sheet of mine and PL is another existent sheet.

If I add watch to the right hand side equation I get the following formula, which when pasted to the cell (manually) does work.

=23,45/PL!C2

The error I'm getting is:

Run-time error '1004':
Application-defined or object-defined error

I've looked into several run time error 1004 questions but none of them seem to either be the same issue or work for me. Any ideas ? thanks

解决方案

Use the Range.Formula property with EN-US syntax or Range.FormulaLocal property with your regional locale settings.

Worksheets("Charts").Cells(2, 7).FORMULA = "=" & "23.45" & "/PL!C" & 2
Worksheets("Charts").Cells(2, 7).FORMULALOCAL = "=" & "23,45" & "/PL!C" & 2

VBA is very EN-US-centric as providing translation for all regional settings 'on-the-fly' would create a large overhead.

这篇关于VBA代码字符串到单元格不工作 - 运行时错误1004的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆