vba - assign value of cell from another worksheet to a variable -
i cannot cope following issue. have in module code. code working when i'm in sheet2. when skipping sheet1 , run macro returns me 0. i'd appreciate if point @ mistake i've done.
public sub test() dim ws worksheet dim cost double set ws = sheets("sheet1") cost = worksheets("sheet2").application.sum(range("a2:a10")) msgbox cost ws.range("c2") = cost end sub
coz forget put sheet2's name in front of range(a2:a10). , no need specify sheet name before applicaiton. supposed this
cost = application.sum(worksheets("sheet2").range("a2:a10"))
Comments
Post a Comment