|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Changing color in the entire header in Excel via VB?
Hi, I have an excel sheet with header row. Is it anyway to change the hearder background color?? I know we can change the font color via VB using '.Rows(1).Font.ColorIndex = 5' ... but i can't seem find anything to change the background color. Please help. Or is it any side with references about this issue?
|
|
#2
|
||||
|
||||
|
hey HB- I forgot to tell you earlier. When you're looping through fields in your Excel file, you can do this too...
for inti = 1 to rsrecordset.fields.count xlapp.cells (1,inti) = cstr(rsrecordset.fields(inti)) xlapp.cells (1,inti).interior.color = rgb(0,0,0) next inti That will set the first row in the sheet as a header for as many fields as you have in the recordset, with black background. You could also include something like this xlapp.cells(1,inti).font.color = rgb(255,255,255) xlapp.cells(1,inti).border.color = rgb(0,0,0) xlapp.cells(1,inti).font.bold which will set the font color to white, the cell border color to black, and bold the text in the cell. Good Luck!
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
|||
|
|||
|
Thanks, FM ... but where can i find the color code?
|
|
#4
|
||||
|
||||
|
what color code are you wanting to use? If you're not familiar with rgb coding, then here's a brief explanation. The RGB Function of visual basic uses the combination of values representing the amounts of red, green, and blue, respectively, to create the color you want. The values range from 0 to 255, and are designated by rgb(R,G,B). Some examples would be...
RGB(0,0,0) = BLACK because a lack of color is the definition of black RGB(255,255,255) = White, because a light source that includes all colors is white RGB(180,180,180) = Medium Gray RGB(255,0,0) = Red RGB(0,255,0) = Green RGB(0,0,255) = Blue... And you can mix and match combinations to create a color... RGB(255,0,255) = Purple (red + blue) RGB(0,255,255) = Aqua/BlueGreen... and so on. So.. let me ask you, what color are you trying to create? If you google search for RGB color values, you can probably come across an HTML developer's site to give you the values for the color you're looking for. I actually have an ASP page that process all combinations of RGB (to a point, theres an awfully lot of them), and sets them into the background of cells in a table to display them. If you have IIS on your machine, I can send it to you and you can run it to find the color you want. |
|
#5
|
|||
|
|||
|
Thank you very much, FM ...
I actually want Grey But from what you discribed how the color works, I actaully learned a lot Thanks again, FM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Changing color in the entire header in Excel via VB? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|