excel - VBA Macro to search for value then increment -


i learned macros week , looking (if question possible)..what run macro searches column c #1..then in each of cells below increase number until reaches full cell (the next section)..then find next #1 , on , forth until end. if possible guidance , expertise appreciated! i've added mock-up below. keep in mind i've used small numbers example.

pre-macro

enter image description here

post-macro

enter image description here

answer via ol' macro recorder:

sub macro1()   range("c1:c10").select   selection.specialcells(xlcelltypeblanks).select   selection.formular1c1 = "=r[-1]c+1" end sub 

edit: update populate within region made contiguous based on populated column b per comments.

sub macro2()   range("b1").select   selection.currentregion.select   selection.offset(0, 1).resize(, 1).select   selection.specialcells(xlcelltypeblanks).select   selection.formular1c1 = "=r[-1]c+1" end sub 

or, if not contiguous, wishing populate last row populated in column b

sub macro3()   range("b1", range("b1048576").end(xlup)).select   selection.offset(0, 1).resize(, 1).select   selection.specialcells(xlcelltypeblanks).select   selection.formular1c1 = "=r[-1]c+1" end sub 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -