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:
- make
$a$1:$a$30red - make
$b$1:$b$30blue selecta10:b10, copy/pastea20:b20.
excel delete conditional formatting.
for a20:b20 rules applied cells , add new rules have formatting a20:b20. end 4 rules:
- make
=$a$20red - make
=$b$20blue - make
=$a$1:$a$19,$a$21:$a$30red - make
=$b$1:$b$19,$b$21:$b$30blue
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
if don't want go way you'll need use windows api:
Comments
Post a Comment