Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Excel注释-VBA中追加文本时遇到错误_Excel_Vba - Fatal编程技术网

在Excel注释-VBA中追加文本时遇到错误

在Excel注释-VBA中追加文本时遇到错误,excel,vba,Excel,Vba,下面是我试图将新文本附加到现有注释的代码。然而,当我执行时,它会抛出一个错误——“应用程序定义的/对象定义的错误”。有人能帮忙吗 For Each c In Range("G" & iCellIndex) If StrComp(JSONObj2("fields")("worklog")("worklogs")(j + 1)("author")("displayName"), Range("G" & iCellIndex).Value) = 0 Then Set cm

下面是我试图将新文本附加到现有注释的代码。然而,当我执行时,它会抛出一个错误——“应用程序定义的/对象定义的错误”。有人能帮忙吗

For Each c In Range("G" & iCellIndex)
  If StrComp(JSONObj2("fields")("worklog")("worklogs")(j + 1)("author")("displayName"), Range("G" & iCellIndex).Value) = 0 Then
     Set cmt = ActiveCell.AddComment
     cmt.Comment.Text iTimeStamp & "--" & JSONObj2("fields")("worklog")("worklogs")(j + 1)("timeSpent") , 1, False
     Range("G" & iCellIndex).AddComment iTimeStamp & "--" & JSONObj2("fields")("worklog")("worklogs")(j + 1)("timeSpent") , 1, False
  End If
  iCellIndex = iCellIndex + 1
Next c

对于那些感兴趣的人,我是这样解决这个问题的:

If StrComp(JSONObj2("fields")("worklog")("worklogs")(j + 1)("author")("displayName"), Range("G" & iCellIndex).Value) = 0 Then
   Range("G" & iCellIndex).NoteText Text:=Range("G" & iCellIndex).NoteText & Chr(10) & iTimeStamp & "   --   " & JSONObj2("fields")("worklog")("worklogs")(j + 1)("timeSpent") & Chr(10)
End If

哪一行抛出错误?这一行--cmt.Comment.Text iTimeStamp&“--”&JSONObj2(“字段”)(“工作日志”)(“工作日志”)(“时间戳”)(j+1)(“时间戳”),1,FalseOh,当我执行“Ctrl+v”时,“cv”是一个复制错误:)修复了它!试着将抛出错误的行分成多行,看看是哪一部分导致了问题。我知道有些人不希望为了鼓励自学而“交”代码/答案。但是,恕我直言,在某些情况下,提问者可能没有时间和智慧,这就是为什么他们求助于这样的论坛。我确实尽了最大的努力来纠正错误,但我的脑子里已经没有什么想法了。所以,如果你能比神秘的“分开”更具体一点,我将不胜感激,当然,如果你愿意帮忙的话。