Setting Cell BackColors From VBA

A

AndrewDB

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
 
A

AndrewDB

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
 
M

Mike H

Andrew,

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

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

Mike
 
A

AndrewDB

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
 
G

Gord Dibben

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top