excel vba - I am using Sumif function in macro but the result is not getting -


i have used below code answer. m getting result @ required location sum not displayed.

cells(lastrow, 2).offset(3, 1).value = "=sumif(l4:l" & lastrow & "," & "new albertsons inc" & ",j4:j" & lastrow - 1 & ")" 

could 1 me how sort out.

try one:

cells(lastrow, 2).offset(3, 1).formula = "=sumif(l4:l" & lastrow & "," & """new albertsons inc""" & ",j4:j" & lastrow & ")" 

some notes:

  • i'm using """new albertsons inc""" instead "new albertsons inc" (you should escape quotes when constucting excel formulas through vba)
  • sum_range , criteria_range should have same dimmentsion, that's why should use l4:l" & lastrow , j4:j" & lastrow (or & lastrow-1 both ranges)
  • actually, can simplify formula changing "," & """new albertsons inc""" ", ""new albertsons inc"""

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -