Excel VBA: Trigger macro on cut/paste/delete/insert events -


i have conditional formatting rule defined macro, deletes old rules , replaces them updates ones:

sub setcondformat()     set table = activesheet.listobjects("rules")     table.range.formatconditions.delete     set attribute = table.listcolumns("attribute")     attribute.databodyrange.formatconditions _     .add(xlexpression, xlequal, "=isempty(a2)")         .interior             .colorindex = 0         end     end end sub 

the conditional formatting in excel needs updated. otherwise cell ranges in rules fragmented.

let's have 2 rules:

  1. make $a$1:$a$30 red
  2. make $b$1:$b$30 blue select a10:b10 , copy/paste a20:b20.
    excel delete conditional formatting.

for a20:b20 rules applied cells , add new rules have formatting a20:b20. end 4 rules:

  1. make =$a$20 red
  2. make =$b$20 blue
  3. make =$a$1:$a$19,$a$21:$a$30 red
  4. make =$b$1:$b$19,$b$21:$b$30 blue

this happens, when table structure gets changed through cut/paste/delete/insert events.

how trigger above vba macro on cut/paste/delete/insert events?

you use shortcut macro

vba event trigger on copy?

if don't want go way you'll need use windows api:

is there event fires when keys pressed when editing cell?


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -