This line of code:
这行代码:
Y.Sheets(1).Cells(i, 1) = Y.Sheets(1).Cells(i, 1).value & " (" & Right(UserAndEid, Len(UserAndEid) - InStr(1, UserAndEid, "Emp") - 7) & ")"
Throws this error:
引发此错误:
Excel (2007) VBA Object doesn't support this property or method
Excel(2007)VBA对象不支持此属性或方法
Y
is a declared workbook variable. Sheets(1)
is the sheet I am addressing (not using the sheet caption name as it is changed by the same procedure). UserAndEid
is a piece of text taken from a cell in another declared workbook.
Y是声明的工作簿变量。表格(1)是我正在处理的表格(不使用表格标题名称,因为它通过相同的程序更改)。 UserAndEid是从另一个声明的工作簿中的单元格中获取的一段文本。
All I am doing is adding the peice of text to that which is already in the cell in row "A". I had it working yesterday, am sure I haven't changed anything, but today it will not work.
我所做的只是将文本的句子添加到已经在“A”行中的单元格中。我昨天有工作,我确定我没有改变任何东西,但今天它不会工作。
Any ideas?
有任何想法吗?
Edit UserAndEid is declared as a string but will contain numbers.
编辑UserAndEid声明为字符串,但将包含数字。
Dim UserAndEid As String
The whole line is highlighted in yellow in the debugger.
整行在调试器中以黄色突出显示。
1 个解决方案
#1
0
Thanks to all for the pointers,they helped me find the issue:
感谢大家指点,他们帮我找到了问题:
Sheets(1)
I remembered that I had added a chart to the workbook and this was Chart1
. As Sheets
includes Charts and Worksheets the addition of Chart1
made Sheets(1)
ambiguous, as it could no longer only be referring to 'Worksheets1'.
我记得我在工作簿中添加了一个图表,这是Chart1。由于表格包含图表和工作表,因此Chart1的添加使得表格(1)不明确,因为它不再仅仅指“工作表1”。
I have to say that the error message could have helped more here - if a variable is ambiguous the error message will say so, why not in the case of objects?
我不得不说错误信息可能在这里有所帮助 - 如果变量不明确,错误信息会这样说,为什么不在对象的情况下呢?
#1
0
Thanks to all for the pointers,they helped me find the issue:
感谢大家指点,他们帮我找到了问题:
Sheets(1)
I remembered that I had added a chart to the workbook and this was Chart1
. As Sheets
includes Charts and Worksheets the addition of Chart1
made Sheets(1)
ambiguous, as it could no longer only be referring to 'Worksheets1'.
我记得我在工作簿中添加了一个图表,这是Chart1。由于表格包含图表和工作表,因此Chart1的添加使得表格(1)不明确,因为它不再仅仅指“工作表1”。
I have to say that the error message could have helped more here - if a variable is ambiguous the error message will say so, why not in the case of objects?
我不得不说错误信息可能在这里有所帮助 - 如果变量不明确,错误信息会这样说,为什么不在对象的情况下呢?