excel - Sorting column triggers click to run Macro...How do I fix this? -


i have code runs macro when cells clicked. problem sorting column causes macro run. how can prevent code running when column sorted?

private sub worksheet_selectionchange(byval target range)     if selection.count = 1         if not intersect(target, range("ai13:ai10000")) nothing             msgbox "hello world!"         end if     end if end sub 

i'm pretty sure it's irrelevant, rest of code taking values 1 workbook , using filter pivot tables in workbook.

thanks!

sorting trigger worksheet_selectionchange because range selected in sorting process. using worksheet_beforedoubleclick instead run macro double click on desired cell , event not triggered sorting.

the following code worked me:

private sub worksheet_beforedoubleclick(byval target range, cancel boolean)     if selection.count = 1         if not intersect(target, range("ai13:ai10000")) nothing             msgbox "hello world!"         end if     end if end sub 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -