Error handling for merging cells in Excel VBA -


i'm developing add-in excel automatically format table. users has follow specific format when preparing table, or else common error of "merging cells keeps upper-left cell value, , discards other values." bound appear.

i mute alert excel, still catch error , pass different message users terminate sub. i've tried this:

sub formattable()     on error goto errhandler     application.displayalerts = false     'codes formatting table     exit sub errhandler:     msgbox "incorrect formatting. terminating process conserve data." end sub 

however, realise using "application.displayalerts = false" cause excel choose default action , proceed merge cells causes big mess. not go errhandler. there way making happen? thank you.

you test merged cells in selected range prior running code:

public function hasmergedcells(orng range)     dim ocell range     dim oarea range     each oarea in orng.areas         each ocell in oarea.cells             if ocell.mergearea.mergecells                 hasmergedcells = true                 exit function             end if         next     next end function 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -