Automatically set value to empty cells in Excel when another cell is populated -
i have spreadsheet tracks information on shared network drive. when user adds row, entering data next available row, cell b, want set few other cells default values. instance, cell should 1up number, cell c should user name, , cell d should current date, time stamp.
individually, know how pieces, not know how set cells when cell b changed blank not blank.
i not opposed using vba, avoid if possible.
some of things wish record easier vba. use following worksheet event macro:
private sub worksheet_change(byval target range) dim s string if intersect(target, range("b:b")) nothing exit sub ary = split(environ("homepath"), "\") s = ary(ubound(ary)) application.enableevents = false target .offset(0, -1).value = .offset(-1, -1).value + 1 .offset(0, 1).value = s .offset(0, 2).value = end application.enableevents = true end sub
because worksheet code, easy install , automatic use:
- right-click tab name near bottom of excel window
- select view code - brings vbe window
- paste stuff in , close vbe window
if have concerns, first try on trial worksheet.
if save workbook, macro saved it. if using version of excel later 2003, must save file .xlsm rather .xlsx
to remove macro:
- bring vbe windows above
- clear code out
- close vbe window
to learn more macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
to learn more event macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
macros must enabled work!
Comments
Post a Comment