Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2006

Tip: Looking for answers? Try searching our database.

VBA Help:Change Color of Cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Lie - 25 Jan 2006 02:18 GMT
Dear All,

How to change the color of cells?
I'm confused whether to use range object or cells object.
Pls give me example.

Thanks

Robert Lie
Norman Jones - 25 Jan 2006 02:24 GMT
Hi Robert,

The Cells property returns a range object, so you could, for example, use
either of the following equivalent instructions:

       Range("A1:A10").Interior.ColorIndex = 6

       Cells(1, 1).Resize(10).Interior.ColorIndex = 6

---
Regards,
Norman

> Dear All,
>
[quoted text clipped - 5 lines]
>
> Robert Lie
Robert Lie - 25 Jan 2006 02:56 GMT
Hi All,

I need give a specific color for the cells.
Do you could give me the list of colorindex, since I couldn't find the
list from VBA Help?

Thanks

Robert Lie

> Hi Robert,
>
[quoted text clipped - 18 lines]
>>
>>Robert Lie
Norman Jones - 25 Jan 2006 03:03 GMT
Hi Robert,

With a blank worksheet active try:

'===============>>
Sub ColourTable()
   Dim iCtr As Long

   For iCtr = 1 To 56
       Cells(iCtr, 1).Interior.ColorIndex = iCtr
       Cells(iCtr, 2).Value = "'" & Right("000000" & _
                           Hex(ThisWorkbook.Colors(iCtr)), 6)
       Cells(iCtr, 3).Value = iCtr
       Cells(iCtr, 4).Value = Cells(iCtr, 1).Interior.Color
       Cells(iCtr, 2).Font.Name = "Courier New"
       Cells(iCtr, 2).HorizontalAlignment = xlRight
       Cells(iCtr, 3).HorizontalAlignment = xlCenter
       Cells(iCtr, 4).HorizontalAlignment = xlLeft
   Next iCtr

End Sub
'<<===============

See also David McRitchie's Color page at:

       http://www.mvps.org/dmcritchie/excel/colors.htm

---
Regards,
Norman

> Hi All,
>
[quoted text clipped - 28 lines]
>>>
>>>Robert Lie
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.