Excel VBA Timestamp not updating -
i have worksheet building track our incoming trailers , put information on dashboard. have vba setup when user changes cell in column here closed, copy line next sheet keep history of trailers.
my problem vba timestamp on completed page not updating when line copied over. know vba works can change trailer number on completed sheet , trigger vba , timestamp appear. need timestamp appear when line copied dashboard sheet.
am missing need turn on trigger timestamp?
thanks
edit- sorry didn't add in code. here have timestamp on completed sheet
private sub worksheet_change(byval target range) if intersect(target, range("c2:c10000")) nothing exit sub if target.count > 1 exit sub if target = "" exit sub application .screenupdating = false .enableevents = false cells(target.row, 10) .value = .numberformat = "mm/dd/yyyy hh:mm:ss" end .enableevents = true .screenupdating = true end end sub
code dashboard page copy line over
private sub worksheet_change(byval target range) if intersect(target, range("a2:a5000")) nothing exit sub if target.count > 1 exit sub if target = "" exit sub dim nr long application .enableevents = false .screenupdating = false select case target.value case "closed" range("a" & target.row & ":z" & target.row).copy _ worksheets("completed").range("a" & rows.count).end(xlup).offset(1, 0) target.entirerow.delete shift:=xlup end select .enableevents = true .screenupdating = true end end sub
here solution came with. don't see why need have 2 worksheet functions when 1 suffice. place code in dashboard worksheet , copy , paste completed worksheet. there few things added code. firstly, error handling, if there error , .enableevents = false
1 of last line executes, subsequent events not fire , not happy yourself. added few end if
seem missing code. added comments code understand made changes.
private sub worksheet_change(byval target range) on error goto errorhandler if intersect(target, range("a2:a5000")) nothing _ exit sub if target.count > 1 exit sub end if if target = "" exit sub end if dim nr long application .enableevents = false .screenupdating = false select case target.value case "closed" range("a" & target.row & ":z" & target.row).copy _ worksheets("completed").range("a" & rows.count).end(xlup).offset(1, 0) 'get last cell used. set lastcell = worksheets("completed").range("a" & rows.count).end(xlup) 'new line of code lastcell.offset(0, 10).value = lastcell.offset(0, 10).numberformat = "mm/dd/yyyy hh:mm:ss" target.entirerow.delete shift:=xlup end select .enableevents = true .screenupdating = true end exit sub errorhandler: application.enableevents = true application.screenupdating = true msgbox "you have encountered error. please notify admin" end sub
Comments
Post a Comment