vba - Message when a cell (List values) value is changed -


i relatively new vba.

i have table range(e16:dw39), each cell has dropdown menu (data validation = list) pick value manually @ same time have macro copy data worksheet (two ways populate table).

i want message every time user changes cell value manually.

i want able still run macro (as noticed cannot after adding following code) independently. intersect check want manual data input.

in order check have following code (in specific sheet):

private sub worksheet_change(byval target range) ------------------------------------------------------ dim myrange range  myrange = range("e16:dw39") '-> mission mix table  if intersect(myrange, target)  msgbox "mission plan not matching change"  end if  end sub ------------------------------------------------ 

i following error

run-time error 91: object variable or block variable not set

when tried change cell value 1 dropdown menu, above error, idea how solve problem?

please notice due code cannot run running fine copy macro.

the error code because referencing null object when 2 ranges dont intersect. fix:

if intersect(myrange, target) nothing then... 

if want process changes happen excel gui , not code, usual approach use application.enableevents = false @ beginning of macros, application.enableevents = true @ end of macro. way, change made inside macro not toggle event handling.

private sub worksheet_change(byval target range)         on error goto finish         dim myrange range          set myrange = range("e16:dw39") ' <~~ dont forget "set"         if not intersect(myrange, target) nothing             msgbox ...         end if     finish:         application.enableevents = true end sub 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -