vba - Get value from another sheet -


i'm having trouble trying make code work:

private sub worksheet_change(byval target range)  static zeroflag boolean  dim keycells range   set keycells = range("b29")  on error resume next  set keycells = application.union(keycells, keycells.precedents)  on error goto 0   if not application.intersect(target, keycells) nothing      if (range("b29").value <= 0) xor zeroflag          msgbox iif(zeroflag, "not zero", "zero")          zeroflag = not (zeroflag)      end if  end if  end sub  

the thing is, alert shows when change values sheet "b29" need alert show when alter values other sheets too.

for example: "b29" cell located on sheet , result of a1-a2, a2 getting value cell a1 @ b sheet alert showing if alter cell a2 sheet , not a1 b sheet.

what can make work?

when first started work on code looked , work when altered value diferents sheets

private sub worksheet_calculate()  if range("b29").value <= "0"      msgbox "zero"  else      msgbox "not zero"  end if end sub  

but code not have rules need.

until cell bigger 0 alert not show up, when value below 0 alert shows "zero" , long value remains below 0 stop showing, moment value bigger 0 alert shows " not zero" long value remains above 0 stop showing.

what can make work?

thanks

instead of writing code in worksheet_change you'll have write code in workbook_sheetchange as:

private sub workbook_sheetchange(byval sh object, byval target range)      '....write code here  end sub 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -