Reputation: 113
I am trying to grab the last cell for my average, so I have it pulling a count from column A since column A does not have blanks, and determines the stopping point for my other columns. This works for my range functions, but I keep getting a compile error for "Expected: end of statement" when I use the below.
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("H2").Formula = "=IFERROR(AVERAGE("H3:H" & lastrow), """")"
The output would be something like if column A had 200 lines, the forumla would input as =IFERROR(AVERAGE(H2:H200),"")
Upvotes: 1
Views: 1316
Reputation: 152450
the H2:H
is part of the string and not in ""
.
Range("H2").Formula = "=IFERROR(AVERAGE(H2:H" & lastrow & "), """")"
Upvotes: 3