ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting Cell BackColors From VBA (https://www.excelbanter.com/excel-programming/434718-setting-cell-backcolors-vba.html)

AndrewDB

Setting Cell BackColors From VBA
 
Hi All. I need to create a spreadsheet from VBA in Access and set the
backcolors of certain cells depending on data values. All works well but how
do I set the cell/range back colors using VBA? Please Help.

Regards


Mike H

Setting Cell BackColors From VBA
 
Maybe this

Range("A1:A6").Interior.ColorIndex = 3
Mike

"AndrewDB" wrote:

Hi All. I need to create a spreadsheet from VBA in Access and set the
backcolors of certain cells depending on data values. All works well but how
do I set the cell/range back colors using VBA? Please Help.

Regards


AndrewDB

Setting Cell BackColors From VBA
 
Hi Mike,

Thanks for your quick response. Is there any way that I can set the color
using RGB value? Seems the colorindex range is very limited.

Andrew
--
Kepior Senso Fumor


"Mike H" wrote:

Maybe this

Range("A1:A6").Interior.ColorIndex = 3
Mike

"AndrewDB" wrote:

Hi All. I need to create a spreadsheet from VBA in Access and set the
backcolors of certain cells depending on data values. All works well but how
do I set the cell/range back colors using VBA? Please Help.

Regards


Mike H

Setting Cell BackColors From VBA
 
Andrew,

Look in Help for the different colours using RGB. This is Blue

Range("A1:A6").Interior.Color = RGB(0, 0, 255)

Mike

"AndrewDB" wrote:

Hi Mike,

Thanks for your quick response. Is there any way that I can set the color
using RGB value? Seems the colorindex range is very limited.

Andrew
--
Kepior Senso Fumor


"Mike H" wrote:

Maybe this

Range("A1:A6").Interior.ColorIndex = 3
Mike

"AndrewDB" wrote:

Hi All. I need to create a spreadsheet from VBA in Access and set the
backcolors of certain cells depending on data values. All works well but how
do I set the cell/range back colors using VBA? Please Help.

Regards


AndrewDB

Setting Cell BackColors From VBA
 
Hi Mike

For some reason my Access VBA does not accept the "= RGB(0,0,255)" code. I'm
using Access and Excell 2007.

Regards
Andrew

"Mike H" wrote:

Andrew,

Look in Help for the different colours using RGB. This is Blue

Range("A1:A6").Interior.Color = RGB(0, 0, 255)

Mike

"AndrewDB" wrote:

Hi Mike,

Thanks for your quick response. Is there any way that I can set the color
using RGB value? Seems the colorindex range is very limited.

Andrew
--
Kepior Senso Fumor


"Mike H" wrote:

Maybe this

Range("A1:A6").Interior.ColorIndex = 3
Mike

"AndrewDB" wrote:

Hi All. I need to create a spreadsheet from VBA in Access and set the
backcolors of certain cells depending on data values. All works well but how
do I set the cell/range back colors using VBA? Please Help.

Regards


Gord Dibben

Setting Cell BackColors From VBA
 
Why not use the Excel built-in features of Conditional formatting?

Do you need it to be VBA?

Sub backcolor()
ActiveSheet.Range("A1:G23").Interior.ColorIndex = 3
End Sub


Gord Dibben MS Excel MVP

On Thu, 8 Oct 2009 07:25:01 -0700, AndrewDB
wrote:

Hi All. I need to create a spreadsheet from VBA in Access and set the
backcolors of certain cells depending on data values. All works well but how
do I set the cell/range back colors using VBA? Please Help.

Regards




All times are GMT +1. The time now is 10:35 AM.

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