ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Background color change (https://www.excelbanter.com/excel-programming/364183-background-color-change.html)

Leif

Background color change
 
I have a VBA routine, run from Access, that writes out data to an spreadsheet
(using Automation). In my spreadsheet I've added a routine to change the
background color of any cell that is changed. The problem is, my Access
program, in populating the spreadsheet, is causing the background to change
as it writes values to the spreadsheet. I only want the background to change
by a user, after the spreadsheet is populated

Is there a way to do that? If I can programmatically add the event
procedure to the spreadsheet after is is populated that would problaby do it.
However, i don't know how to do that, or if it can be done. Thanks for your
help.

Regards,
Leif

Tom Ogilvy

Background color change
 
the first choice is
xlApp.EnableEvents = False

but it is recognized that in some verions of Excel, this doesn't work. So
next,

Why not simply

Cells.Interior.ColorIndex = -4142 ' xlNone

after you are done updating.

or restrict this code to the range where you were working.

an alternative would be a cell that is normally blank but you place a value
in it when you are ready to write.

You change routine would be altered to not color this cell and not color any
cell if this cell contains a value. then clear this cell at the end.

Adding the event procedure would be a distant choice for me.
http://www.cpearson.com/excel/vbe.htm


--
Regards,
Tom Ogilvy



"Leif" wrote:

I have a VBA routine, run from Access, that writes out data to an spreadsheet
(using Automation). In my spreadsheet I've added a routine to change the
background color of any cell that is changed. The problem is, my Access
program, in populating the spreadsheet, is causing the background to change
as it writes values to the spreadsheet. I only want the background to change
by a user, after the spreadsheet is populated

Is there a way to do that? If I can programmatically add the event
procedure to the spreadsheet after is is populated that would problaby do it.
However, i don't know how to do that, or if it can be done. Thanks for your
help.

Regards,
Leif



All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com