excel - Add Total Row For Columns D - M -
i have been using syntax add total row column d - need add total row d - m. instead of writing code multiple times , changing column name there quick re-usable function add total row bottom of columns d - m?
with activesheet if application.worksheetfunction.counta(.cells) <> 0 lastrow = .cells.find(what:="*", _ after:=.range("d1"), _ lookat:=xlpart, _ lookin:=xlformulas, _ searchorder:=xlbyrows, _ searchdirection:=xlprevious, _ matchcase:=false).row else lastrow = 1 end if end range("d" & lastrow +1).formular1c1 = "=sum(r[-" & lastrow & "]c:r[-1]c)"
this has same effect highlighting range , hitting ctrl+right arrow
range("d" & lastrow + 1 & ":m" & lastrow + 1).fillright
Comments
Post a Comment