excel - Change value of cell based on its on value -
i wondering how make if put 1 in cell a1 value of cell a1 change.
i want make value of a1 10 if 1 inputed.
sorry if confusing.
thanks.
enter following event macro in worksheet code area:
private sub worksheet_change(byval target range) dim range set = range("a1") if intersect(a, target) nothing exit sub if target.count > 1 exit sub if target.value <> 1 exit sub application.enableevents = false a.value = 10 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