excel - Auto-filling a column with data once one cell has been updated -


how can auto-fill column 0's once 1 cell in column has been filled?

example:

original table

original table

once enter number cell in april column... enter image description here

i want column auto-fill rest of cells 0's, this... enter image description here

my first idea use worksheet_change event so...

private sub worksheet_change(byval target range) dim keycells range set keycells = range("h6:h16") 'h6 h16 range of april column, repeat each column in loop  if not application.intersect(keycells, range(target.address)) nothing     range("h6:h16").value = 0  end if end sub 

but overwrites entire column, while want keep original value.

is there way excel return cell changed can change value of cells in column except one? or there easier way this?

with apr in h6:h16, data range seem in e6:p16.

private sub worksheet_change(byval target range)     if not intersect(target, range("e6:p16")) nothing         on error goto bm_safe_exit         application.enableevents = false         dim tgt range, var variant         each tgt in intersect(target, range("e6:p16"))             cells(6, tgt.column).resize(11, 1)                 if application.count(.cells) = 1                     var = tgt.value                     .cells = 0                     tgt = var                 end if             end         next tgt     end if bm_safe_exit:     application.enableevents = true end sub 

always disable event handling before writing values worksheet or trigger worksheet_change event macro runs on top of original possibly triggering cascade of events.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -