excel vba - worksheet_SelectionChange for a specific column -
i have worksheet contains invoice numbers in column d. i'd re-create invoice number worksheet ("details") when 1 selected. i've added "if isnumeric" status create sure cells containing invoice # copied over. code seems nothing, can help point me in right direction?
private sub worksheet_selectionchange(byval target range) if target.column = 4 on error resume next application.enableevents = false if isnumeric(target.value) sheets("detail").range("a5").value = target.value application.enableevents = true sheets("detail").activate end if end if end sub
rather than:
isnumeric(target.address)
try
isnumeric(target)
edit#1:
try this:
private sub worksheet_selectionchange(byval target range) if target.column = 4 application.enableevents = false if isnumeric(target.value) target.copy sheets("detail").range("a5") end if application.enableevents = true end if end sub
edit#2:
you need re-enable events within same if
private sub worksheet_selectionchange(byval target range) if target.column = 4 on error resume next if isnumeric(target.value) application.enableevents = false sheets("detail").range("a5").value = target.value sheets("detail").activate application.enableevents = true end if end if end sub
excel-vba events
No comments:
Post a Comment