Below is my code that I am trying to append new text to an existing comment. However, when I execute, it is spitting an error - "Application defined/Object defined error". Could someone help?
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
For those interested, this is how I fixed the issue:
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
Related
For i = 2 To 50
ws.Range("K" & i).FormulaLocal = "=if(countif($C$2:C" & i & ";C" & i & ")=1;row();"")"
Next i
ws.Range("K" & i).FormulaLocal = "=if(countif($C$2:C" & i & ";C" & i & ")=1;row();"")
I am getting error on this line. Where am I going wrong?
you need to double the quotation marks within the string (at the end):
ws.Range("K" & i).FormulaLocal = "=if(countif($C$2:C" & i & ";C" & i & ")=1;row();"""")"
I have the following issue: I create a chart from values that a user will insert in specific cells of a spreadsheet and the chart displays what I expect (The series are collected in the right way). The Series are created consecutively with 2 data points only. I want to store the Xvalues (And YValues) of the series in dynamic arrays for performing calculations later (outside the series collection loop). I tried the following but the arrays only store the last values of the Series (despite using redim preserve everywhere).
Is it because the array is not redimensioned correctly?
Thanks for your help!
i = 1
SeriesAddedA = 1
RangeOccupiedA = Range("A2").End(xlDown).Row
RangeOccupiedB = Range("B2").End(xlDown).Row
MaxRangeOccupied = WorksheetFunction.Max(RangeOccupiedA, RangeOccupiedB)
Dim XValuesA()
Dim YValuesA()
ReDim XValues(RangeOccupiedA + 2)
ReDim YValues(RangeOccupiedA + 2)
Do While i < MaxRangeOccupied
FilledCompA = NextFilled(Cells(i, 1))
PrevCell = PrevFilled(Cells(i + 1, 1))
rowdiff = FilledCompA - PrevCell
If rowdiff < 2 And PrevCell <> 0 And FilledCompA <> 0 Then
ReDim Preserve XValuesA(1 To RangeOccupiedA + 2)
chart.SeriesCollection.NewSeries
chart.FullSeriesCollection(SeriesAddedA).Name = "Reaction Step A " & SeriesAddedA - 1
chart.FullSeriesCollection(SeriesAddedA).XValues = "=" & "'" & ActiveSheet.Name & "'" & "!$E$" & FilledCompA - 1 & ":$E$" & FilledCompA
chart.FullSeriesCollection(SeriesAddedA).Values = "=" & "'" & ActiveSheet.Name & "'" & "!$M$" & FilledCompA - 1 & ":$M$" & FilledCompA
XValuesA() = chart.SeriesCollection(SeriesAddedA).XValues
SeriesAddedA = chart.SeriesCollection.Count + 1
ElseIf PrevCell <> 0 And rowdiff > 0 Then
ReDim Preserve XValuesA(1 To RangeOccupiedA + 2)
chart.SeriesCollection.NewSeries
chart.FullSeriesCollection(SeriesAddedA).Name = "Reaction Step prev A " & SeriesAddedA - 1
chart.FullSeriesCollection(SeriesAddedA).XValues = "=" & "(" & "'" & ActiveSheet.Name & "'" & "!$E$" & FilledCompA - rowdiff & "," & "'" & ActiveSheet.Name & "'" & "!$E$" & FilledCompA & ")"
chart.FullSeriesCollection(SeriesAddedA).Values = "=" & "(" & "'" & ActiveSheet.Name & "'" & "!$M$" & FilledCompA - rowdiff & "," & "'" & ActiveSheet.Name & "'" & "!$M$" & FilledCompA & ")"
XValuesA() = chart.SeriesCollection(SeriesAddedA).XValues
SeriesAddedA = chart.SeriesCollection.Count + 1
End If
loop
'the debug print says:
XvaluesA(1) 310.52
XvaluesA(2) 408.58
With XValuesA() = chart.SeriesCollection(SeriesAddedA).XValues you overwrite the data in XValuesA everytime you call it in your loop. That is why it only contains the last values.
Use XValuesA(i) = chart.SeriesCollection(SeriesAddedA).XValues instead and then
Debug.Print XvaluesA(1)(1)
Debug.Print XvaluesA(1)(2)
gives the first values and
Debug.Print XvaluesA(2)(1)
Debug.Print XvaluesA(2)(2)
the second …
Twsht.Cells(Trow + 1, 15).Formula = "=IFERROR(VLOOKUP(M" & Trow + 1 & Chr(38) & "-" & Chr(38) & "N" & Trow + 1 & ",'Table Array'!$A$2:$D$26,4,FALSE)," & Chr(34) & Chr(34) & ")"
Getting below error message
"Run-Time error 1004"
Application-defined or object-defined error
if i paste below formula directly in cell it working
=IFERROR(VLOOKUP(M604&-N604,'Table Array'!$A$2:$D$26,4,FALSE),"")
use:
Twsht.Cells(Trow + 1, 15).Formula = "=IFERROR(VLOOKUP(M" & Trow + 1 & "&-N" & Trow + 1 & ",'Table Array'!$A$2:$D$26,4,FALSE),"""")"
I am trying to code this forumla in vba.
=MMULT(TRANSPOSE(F124:F370-L124),G124:G370-L125)/246
The code in vba I written looks like this:
Sheets("1.A").Cells(124, 14) = Application.WorksheetFunction.MMult(Application.WorksheetFunction.Transpose(Worksheets("1.A").Range("F" & matchStartRow & ":F" & matchEndRow) - Cells(124, 12)), Worksheets("1.A").Range("G" & matchStartRow & ":G" & matchEndRow) - Cells(125, 12)) / (matchEndRow - matchStartRow)
But it is giving me a type mismatch error. Not sure where it is coming from
It is much easier to use EVALUATE either directly as
Sheets("1.A").Cells(124, 14) = Evaluate("=MMULT(TRANSPOSE(F124:F370-L124),G124:G370-L125)/246")
or with your variables
Dim strEval As String
matchStartRow = 124
matchEndRow = 370
strEval = "=MMULT(TRANSPOSE(F" & matchStartRow & ":F" & matchEndRow & "-L124),G" & matchStartRow & ":G" & matchEndRow & "-L125)/(" & matchEndRow & " - " & matchStartRow & ")"
Sheets("1.A").Cells(124, 14) = Evaluate(strEval)
I need to write in the cells from Cells(1,1) to Cells(501,1) the formula
=FDSC("-",$C$3,"FG_PRICE(D1)") for line 1
=FDSC("-",$C$3,"FG_PRICE(D2)") for line 2
=FDSC("-",$C$3,"FG_PRICE(D3)") for line 3
Now my vba code is the following one :
Range(Cells(1, 1), Cells(1 + 500, 1)).FormulaR1C1 = "=FDSC(""" & "-" & """,R1C3,""" & " FG_PRICE(RC[3]) " & """)"
I've tested everypart of the code to determine that the last part (FG_PRICE...) is the one that is not working!
The formule that is written in Excel is :
=FDSC("-",$C$1,"FG_PRICE(RC[3])")
How can i do to have D1,D2,etc... and not RC[3]??? I've tried a few things but i can't find it!
Thank you very much for your time and your help!
Use chr(34) to represent quotation marks when you are already working inside quotation marks. For example, change your forumula above to the following:
Range(Cells(1, 1), Cells(1 + 500, 1)).FormulaR1C1 = "=FDSC(" & chr(34) & "-" & chr(34) & ",$C$1," & chr(34) & "FG_PRICE(D1)" & chr(34) & ")"
To put it in a loop, just do the following:
Sub writeFormulas()
Dim i as Integer
For i = 0 to 2
Range(Cells(1, 1), Cells(1 + 500, 1)).FormulaR1C1 = "=FDSC(" & chr(34) & "-" & chr(34) & ",$C$1," & chr(34) & "FG_PRICE(D" & i+1 & ")" & chr(34) & ")"
next i
End Sub