Moving a row from one sheet to another based on a cell value - Microsoft Community
- Get link
- X
- Other Apps
hello there excellers !!
i have sheet called "stock listing" , 1 called "sold items"
when value in column 38 "y" rather "n" want move whole row sold items (which same design stock listing")
i using
end sub
it doesnt seem work ? strange took older version of same excel worked fine.
anybody have ideas !!
would appreciate it.
thanks,
matthew
try running version of macro troubleshoot event code, remember add final end if code (given below trouble shooting macro): also, should run resetevents (at bottom) before doing anything:
private sub worksheet_change(byval target range)
dim lr long
if target.column <> 38 then
msgbox "not column 38"
exit sub
else
if target.value = "y" then
application.enableevents = false
lr = sheets("sold items").range("a" & rows.count).end(xlup).row
rows(target.row).copy destination:=sheets("sold items").range("a" & lr + 1)
target.entirerow.delete
application.enableevents = true
else
msgbox "entry not ""y"""
end if
end if
end sub
'fixed code
private sub worksheet_change(byval target range)
dim lr long
if target.column <> 38 exit sub
if target.value = "y" then
application.enableevents = false
lr = sheets("sold items").range("a" & rows.count).end(xlup).row
rows(target.row).copy destination:=sheets("sold items").range("a" & lr + 1)
target.entirerow.delete
application.enableevents = true
end if
end sub
'you may need this
sub resetevents()
if not application.enableevents then
msgbox "events disabled, reset them work!"
application.enableevents = true
else
msgbox "event code should working....."
end if
end sub
Office / Excel / Microsoft Office Programming / Office 2016
- Get link
- X
- Other Apps
Comments
Post a Comment