-3

I need help translating a common Excel function, into VBA code.

Please see attached screenshot for the code I already have started.

I am using the calculations seen in the screenshot to build a scorecard/grading worksheet. I will need to adjust the rows in each of these, but never the columns.

Once I figure this out, I will then loop these to repeat for each new row as they are added.

image of my code, so far

Screenshot

Community
  • 1
  • 1

1 Answers1

1

When a literal string needs to contain double-quote characters, you need to use two double-quotes in a row for each double-quote you need in the string.

So your string

Range("AP4").Formula = "SUM(COUNTIFS(J3:AR3,{"0","1"}))"

needs to look like this:

Range("AP4").Formula = "SUM(COUNTIFS(J3:AR3,{"“0"”,""1""}))"

You can also do this without putting the formula into the content of the cell like this:

Range("AP4") = WorksheetFunction.SUM(WorksheetFunction.COUNTIFS(J3:AR3,{""0"",""1""}))
M--
  • 25,431
  • 8
  • 61
  • 93
Rich Holton
  • 662
  • 5
  • 12