how to prevent the move of cells in excel when using Worksheet_Change Event -


i have code , works fine. problem after press enter ,in cell "a2" example, instead of moving down cell "a3", - moves cell "e3", makes hard on user type.

any suggestions?

private sub worksheet_change(byval target range)  application.enableevents = false  range("a2:m2").interior.colorindex = 19 dim lastrow long thelastrow = activesheet.usedrange.specialcells(xlcelltypelastcell).row  dim intx variant = 2 thelastrow     if range("a" & i) = range("a" & + 1)         range("a" & + 1 & ":n" & + 1).interior.color = range("a" & i).interior.color         intx = intx + 0     else         range("a" & + 1 & ":n" & + 1).interior.colorindex = 46 - intx      intx = intx + 1     end if next  = 2 thelastrow     range("e" & i).select     activecell.formular1c1 = _             "=if(isblank(rc[-1]),"""",hyperlink(""pcdocs://pcdocs_jlm/""&rc[-1]&""/r"",""link""))" next application.enableevents = true  end sub        

you should avoid using select or activate in vba, so:

private sub worksheet_change(byval target range)  application.enableevents = false  range("a2:m2").interior.colorindex = 19 dim lastrow long thelastrow = activesheet.usedrange.specialcells(xlcelltypelastcell).row  dim intx variant = 2 thelastrow     if range("a" & i) = range("a" & + 1)         range("a" & + 1 & ":n" & + 1).interior.color = range("a" & i).interior.color         intx = intx + 0     else         range("a" & + 1 & ":n" & + 1).interior.colorindex = 46 - intx      intx = intx + 1     end if next  = 2 thelastrow     range("e" & i).formular1c1 = _             "=if(isblank(rc[-1]),"""",hyperlink(""pcdocs://pcdocs_jlm/""&rc[-1]&""/r"",""link""))" next application.enableevents = true  end sub     

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -