Excel VBA - delete recent entry after MsgBox -


i'm struggling excel-vba-code work. want button pop after text entered cell. here, yes leads row being locked , cell being time-stamped, want cancel lead cell entering text being cleared of content.

i can't figure out way delete recent entry. can delete activecell, not recent cell (say write text in a1 , press enter, active cell a2 - or if write text , press somewhere cursor, active cell god knows what).

i hope can me this.

best regards

christian

private sub worksheet_change(byval target range)  if target.column = 2 application.enableevents = false  dim ret_type integer dim strmsg string dim strtitle string  strmsg = "do approve?" & vbcrlf & "warning: action lock current row." strtitle = "approval"      ret_type = msgbox(strmsg, vbyesno + vbquestion, strtitle)  select case ret_type  case 7     msgbox "your input deleted."     exit sub  case 6     cells(target.row, 3).value = date + time     application.enableevents = true     activesheet.unprotect password:="password"     target.entirerow.locked = true     activesheet.protect password:="password"     application.enableevents = true  end select  end if    end sub 

try below code

private sub worksheet_change(byval target range)     if target.column = 2         application.enableevents = false         dim ret_type integer         dim strmsg string         dim strtitle string         strmsg = "do approve?" & vbcrlf & "warning: action lock current row."         strtitle = "approval"         ret_type = msgbox(strmsg, vbyesno + vbquestion, strtitle)         select case ret_type             case 7                 msgbox "your input deleted."                 target.clear                 application.enableevents = true                 exit sub             case 6                 activesheet.unprotect password:="password"                 target.rows.locked = false                 cells(target.row, 3).value = date + time                 'application.enableevents = true                 target.entirerow.locked = true                 activesheet.protect password:="password"                 application.enableevents = true         end select     end if end sub 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -