excel - Increase number by one on different sheet without selecting sheet -
i have macro increase cell 1 on active sheet need change code increase number on different sheet without selecting sheet want increase number on
example: have 5 sheets same , run same macro , 6th sheet have has invoice number need increase 1 without selecting it
here's code i'm using now
range("x1").value = range("x1").value + 1
i've tried
sheets("sheet6").range("o2").value = range("o2").value + 1
but make cell value 1
if cell has nothing or zero, put 1 in cell. if cell has number, put number + 1. if cell has text, bring error.
beware typing range("o2")
take range sheet the code is. it's not "sheet 6". (so if in sheet value empty, result in 1)
use sheets("sheet6") on both sides of assignment.
sheets("sheet6").range("o2").value = sheets("sheet6").range("o2").value + 1
Comments
Post a Comment