vba - Excel Macro - How to merge 2 Different Function of Macros -
i new here , excel macro beginner. need how to..join below macros 1. - function of 1st macro move cell next row once specific cell entered - function of second sub-macro enter timestamp when last specific cell of row entered.
thank you...yanto
the macros:
1st macro(main)
option explicit private sub worksheet_change(byval target range) on error goto whoa application.enableevents = false if not target.cells.countlarge > 1 if not intersect(target, columns(1)) nothing target.offset(, 1).select elseif not intersect(target, columns(2)) nothing target.offset(, 1).select elseif not intersect(target, columns(3)) nothing target.offset(, 1).select elseif not intersect(target, columns(4)) nothing target.offset(1, -3).select end if end if letscontinue: application.enableevents = true exit sub whoa: msgbox err.description resume letscontinue end sub
2nd macro(sub)
private sub worksheet_change1(byval target range) if intersect(target, range("d2:d3000")) nothing exit sub if target.count > 1 exit sub if target = "" exit sub dim lc long application .enableevents = false .screenupdating = false lc = cells(target.row, columns.count).end(xltoleft).column if lc = 1 cells(target.row, lc + 2) = now() elseif lc > 1 cells(target.row, lc + 1) = now() end if .enableevents = true .screenupdating = true end end sub
just call sub macro name in main macro like:
private sub worksheet_change(byval target range) '''''''''''''''''some code'''''''''''''''''''' call worksheet_change1(target) '''''''''''''''''some code'''''''''''''''''''' end sub
Comments
Post a Comment