Excel VBA - strange behavior!

0

Strange behavior in Excel VBA! The code opens a source file, and copies an existing table. Paste the table into a destination file - in the SUPPORT worksheet - and closes the source file. In the destination file there is a worksheet named RENT, where I return the data from the SUPPORT worksheet - only some data. Before manipulating the data in the RENT worksheet, the Cells.Clear command clears the data in this worksheet - RENT, so you can paste new data:

wsDestino.Range("A3:Z500").Clear

The previous data, of course, have been completely deleted, including formatting, where line-by-line formatting with color yes and color was also inserted, using:

wsDestino.Range(Cells(lgLoopLin, "A"), Cells(lgLoopLin, lgUltCol)).Interior.Color = RGB(198, 224, 180)

So far so good. Everything works normally.

But if I unprotect the RENT sheet, select the data, delete with the DELETE key, and the Fill Color icon choose No Fill, and trigger the macro gives the error "Excel has stopped working". Interesting that if I select the data and delete everything manually in the Clean / Clear All icon, the error does not happen. You get the impression that by manually using Fill Color / No Fill, this procedure causes the error to occur.

Of course the intention is not to manually delete. I manually erased the data for testing only. Detail: I use the Application.ScreenUpdate at first as False, re-enabling True at the end.

    
asked by anonymous 01.10.2018 / 20:01

0 answers